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

WHEN Trigger for Things #379

Open
mhbosch opened this issue Jan 6, 2021 · 7 comments
Open

WHEN Trigger for Things #379

mhbosch opened this issue Jan 6, 2021 · 7 comments

Comments

@mhbosch
Copy link

mhbosch commented Jan 6, 2021

Hello,

it is possible to add a When Trigger for Things?
With the DSL Rule, i can observe a thing, with Jython i dont have a trigger for things.

My example for DSL:

rule "Gerät gestört"
when 
 Thing 'homematic:HM-LC-Sw4-DR:PEQ0172029:KEQ0055288' changed from ONLINE to OFFLINE
 then
 logInfo("Heizung", "Die Heizungskontrolle kann nicht erreicht werden")
   sendTelegram("bot1", "Die Heizungskontrolle kann nicht erreicht werden")
end

rule "Gerät gestört"
when 
 Thing 'homematic:HM-LC-Sw4-DR:PEQ0172029:KEQ0055288' changed from OFFLINE to ONLINE
 then
 logInfo("Heizung", "Die Heizungskontrolle kann wieder erreicht werden")
   sendTelegram("bot1", "Die Heizungskontrolle kann wieder erreicht werden")
end

@CrazyIvan359
Copy link
Contributor

It is possible, there is an example in the docstring for when:

@when("Thing kodi:kodi:familyroom changed from ONLINE to OFFLINE")# requires S1636, 2.5M2 or newer

@mhbosch
Copy link
Author

mhbosch commented Jan 7, 2021

Hello,

thanks. I have seen, the string for the Thing was changed with OH3.
Now i tried it a sceond time with the other String and it will works!

@mhbosch mhbosch closed this as completed Jan 7, 2021
@mhbosch
Copy link
Author

mhbosch commented Jan 8, 2021

Hello,

im again.

The Trigger dont have a action.

My Trigger:

@rule("Heizungskontrolle", description="Aenderung bei der Heizungskontrolle", tags=["Script", "Telegram"])
@when("Thing homematic:HM-LC-Sw4-DR:3014F711A061A7D8A98C07FD:KEQ0055288 changed")
def heizungskontrolle(event):
    LogAction.logInfo(u"Heiungskontrolle", "" + ir.getItem(str(event.itemName)).label + " wurde von " + str(event.oldItemState) + " auf " + str(event.itemState) + "geändert")
    actions.get("telegram", "telegram:telegramBot:Telegram_Bot").sendTelegram( ir.getItem(str(event.itemName)).label + " wurde von " + str(event.oldItemState) + " auf " + str(event.itemState) + "geändert")

The Log shows, the Trigger was accepted:
2021-01-08 11:09:45.109 [DEBUG] [jsr223.jython.core.triggers ] - when: target: 'Thing homematic:HM-LC-Sw4-DR:3014F711A061A7D8A98C07FD:KEQ0055288 changed', target_type: 'Thing', trigger_target: 'homematic:HM-LC-Sw4-DR:3014F711A061A7D8A98C07FD:KEQ0055288', trigger_type: 'changed', old_state: 'None', new_state: 'None'

When i have a change, the trigger dont work:
LOG:
Thing 'homematic:HM-LC-Sw4-DR:3014F711A061A7D8A98C07FD:KEQ0055288' changed from OFFLINE (COMMUNICATION_ERROR) to ONLINE

But no error from script or active trigger.

@mhbosch mhbosch reopened this Jan 8, 2021
@mhbosch
Copy link
Author

mhbosch commented Jan 17, 2021

Hello,

thats sound great. It there a Update Script for the library? I think, i miss updates.

@CrazyIvan359
Copy link
Contributor

No, there isn't one. Did you use the manual installation instructions and are you running OH3?

@mhbosch
Copy link
Author

mhbosch commented Jan 17, 2021

Yes, OH3.

I hope, in near future, there is a script, who inform about updates and a update script,

@mhbosch
Copy link
Author

mhbosch commented Jan 20, 2021

OK,

thanks, i will try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants