Push notification


(Jack ) #1

Hello,

I try so send a push notification if the washmaschine finished to wash. I use a Homematic IP Switch and Meter Plug. I have the possibility to switch the plug manually on and off. But I don’t receive a message on the Openhab app, if the maschine was ready. I tried the following rule:

rule "push"
when
Item GF_LaundryRoom_Power_washmaschine_consume < 45.00
then
sendBroadcastNotification("Washmaschine ready ")
end

But I don’t will receive anything. I tried already with another value. But it’s the same result.

Thanks for support!


(Thomas Binder) #2

Please have a look into the logs if rules won’t work. You can’t put off clauses into the trigger.

Item GF_LaundryRoom_Power_washmaschine_consume changed

Then do an if clause in the then section


(Jack ) #3

I have changed the rule. But it still not work.
I checked the log, but I will not find a line which this rules.

Can you show me a sample for this rule?

Thanks!


(Thomas Binder) #4

please post the rule - and have a immediate look into openhab.log after saving it. There must be some entry concerning the rule.


(Jack ) #5
rule "push"
when   
   Item GF_LaundryRoom_Power_Trockner_Verbrauch received update
then   
   If (GF_LaundryRoom_Power_Trockner < 45.00) {    
    sendBroadcastNotification("Trockner fertig ")}
end

In the Logs if found the following line:
Rule ‘push’: The name ‘If’ cannot be resolved to an item or type; line 5, column 4, length 42


(Thomas Binder) #6

That’s why you should always have a log in the logs! :wink:

please write if - no capital letters here! (same goes for else, elseif, switch and so on.)


(Jack ) #7

ok, thanks!
I changed the rules now. But in the Log I get this line:

Refreshing model 'push.rules’
Configuration model ‘push.rules’ is either empty or cannot be parsed correctly!
Loading model ‘push.rules’

Do you think the rule is ok?


(Thomas Binder) #8

yes, that’s normal behaviour if you edit the file via smb or sftp. The first line is triggered as the file is touched (but empty), the second line is triggered as the file is written. If there’s no further notice (INFO or WARN or ERROR) after the last “loading model…” you’re safe! :wink:


(Jack ) #9

That sounds great! :slight_smile:
I will test the next days and give a feedback…

Thank you for your support!!!


(Jack ) #10

So i tried the rule now. But i don‘t received a Push notification.
Should i change the settings of the plug in the CCU2?

Thanks!


(Thomas Binder) #11

That’s probably dependent on two Things:

  1. the logic of your rules at all (if (GF_LaundryRoom_Power_Trockner.state < 45.00) {) - you have to have the “.state” Syntax!
  2. the logic of how you measure your washing machine or dryer
    just have a look here - it’s Sonoff-hardware, but the logic works for your homematic also:
    Washing Machine State Machine

(Jack ) #12

So the rule is now updated, but it doesn’t run. I have the following entry in the log file:

Configuration model ‘push.rules’ has errors, therefore ignoring it: [3,4]: no viable alternative at input ‘.’ [11,4]: no viable alternative at input ‘.’

Configuration model ‘push.rules’ has errors, therefore ignoring it: [3,4]: no viable alternative at input ‘.’ [12,4]: no viable alternative at input ‘.’


(Thomas Binder) #13

just get rid of the .00 - you don’t need it anyways.


(Jack ) #14

i canceled the 00, but I have the same lines in the log file.

I haven’t any Items with “.state” in the Items-list. Can this be the problem? I have only this one:

items


(Thomas Binder) #15

no. That’s completely different. Please have a look at the Basics of rules:

Please read through both and try to adapt to your rules.

tl>dr;
If you have an item, you can address it in a rule of Course. If you don’t add “.state” to that, you’ll get all the meta-data of that item (itemtype, last update, … AND the value). So, if you want to compare something to an item value you MUST add .value to it - But that’s explained in detail above.


(Jack ) #16

I have the perfect rule now:

rule "<name>"
when   
   Item <Item name> changed
then
   if (<Item name>.state < <number>) {
    sendBroadcastNotification("<notice> ")}
end

Many thanks to binderth!!!


(Stuart Hanlon) #17

Hi

I’ve tweaked this a tiny bit to also send the state of the rule’s trigger.

rule "<name>"
when   
   Item <Item name> changed
then
   if (<Item name>.state < <number>) {
    sendBroadcastNotification("<notice> "+ <Item name>.state)}
end

Would this also work with .value ? Etc