Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Enhanced @when trigger for number items #46

Closed
andiwirs opened this issue Dec 9, 2018 · 1 comment
Closed

[Feature Request] Enhanced @when trigger for number items #46

andiwirs opened this issue Dec 9, 2018 · 1 comment

Comments

@andiwirs
Copy link

andiwirs commented Dec 9, 2018

Hello, i would like the idea to enhance the @when trigger for number items so that the rule only triggers when a certain condition is met.

For example:

@when("Item NumberItem changed to <10")
@when("Item NumberItem changed to >=12")
@when("Item NumberItem changed to ==15")
@when("Item NumberItem changed to 10-15") # >=10 and <=15

One of my use cases is a warning if a room gets to moist. At the moment the rule has to trigger every time and check of the condition is met like this:

@rule("rNotificationRoomTooMoist")
@when("Descendent of gUnisenHum changed")
def rNotificationRoomTooMoist(event):
	if event.itemState.floatValue() > 80.0:
		log.warn("Room too moist: " + event.itemName)

In my opinion this would be more elegant and furthermore it does not flood the log that much:

@rule("rNotificationRoomTooMoist")
@when("Descendent of gUnisenHum changed to > 80.0")
def rNotificationRoomTooMoist(event):
	log.warn("Room too moist: " + event.itemName)

Thanks a lot :)

@andiwirs andiwirs changed the title [Feature Request] Enhanded @when trigger for number items [Feature Request] Enhanced @when trigger for number items Dec 9, 2018
@5iver
Copy link
Member

5iver commented Dec 9, 2018

This is very similar to the request to add conditions 😄... code-wise, it's essentially the same. The current triggers provided in ESH (changed, received update, received command) require states. So, you'd end up having the same triggers, but the logic would need to be applied through conditions rather than in the rule. You seem to be really swamped with logs! Check my suggestion in #47. I'll close this one, since it really is the same 47.

@5iver 5iver closed this as completed Dec 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants