How to set up value open/close
Moderators: grovkillen, Stuntteam, TD-er
-
- Normal user
- Posts: 30
- Joined: 09 Apr 2017, 23:27
How to set up value open/close
Hi. Is it possible using Switch input - Switch to set value Open/Close not 0/1?
I'm trying to do the door lock status sending via mqtt to Nettemp. In nettemp i can receive status open/close.
I'm trying to do the door lock status sending via mqtt to Nettemp. In nettemp i can receive status open/close.
Re: How to set up value open/close
The use of variables supports formatting like that, as documented here: https://espeasy.readthedocs.io/en/lates ... red-values
so, your rule could use it like this:
NB: If you want to send a 'state' (Closed/Open) instead of an 'action' (Close/Open) the 'C' transformation should be changed to 'c'.
If 0 means open, and 1 means close, then the transformation should be prefixed with an exclamation mark, so '!C' or '!c' (no quotes should be used for the transformation in the actual rules code, that's just added for readability)
It is currently not (easily) supported to send a transformed value to a controller, so the Controller checkbox on the task should be disabled, as it is sent from rules now.
so, your rule could use it like this:
Code: Select all
on switch#state do // Adjust switch and state to the name of your Device task
Publish,topic/goes/here,[switch#state#C#c] // Adjust also when applicable, sends 'Close' and 'Open' ('C' transformation), with first character capitalized, rest in lower case because of the 'c' justification
endon
If 0 means open, and 1 means close, then the transformation should be prefixed with an exclamation mark, so '!C' or '!c' (no quotes should be used for the transformation in the actual rules code, that's just added for readability)
It is currently not (easily) supported to send a transformed value to a controller, so the Controller checkbox on the task should be disabled, as it is sent from rules now.
/Ton (PayPal.me)
-
- Normal user
- Posts: 30
- Joined: 09 Apr 2017, 23:27
Re: How to set up value open/close
thank You! I will try:)
-
- Normal user
- Posts: 30
- Joined: 09 Apr 2017, 23:27
Re: How to set up value open/close
after almost one year
i have back to this topic.
In link which you posted I found what you meaned.
C: 0 => “CLOSE” 1 => “ OPEN”
c: 0 => “CLOSED” 1 => “ OPEN”
I have been tried something like this:
but in [switch#state#C] i have nothing.
What I'am missing?
![Beschaamd :oops:](./images/smilies/icon_redface.gif)
In link which you posted I found what you meaned.
C: 0 => “CLOSE” 1 => “ OPEN”
c: 0 => “CLOSED” 1 => “ OPEN”
I have been tried something like this:
Code: Select all
on Door_sensor#State do
Publish,homedoor_1,Door_sensor,State,[switch#state#C]
endon
Code: Select all
1280172: EVENT: Door_sensor#State=0
1280187: ACT : Publish,homedoor_1,Door_sensor,State,
1284790: EVENT: Door_sensor#State=1
1284801: ACT : Publish,homedoor_1,Door_sensor,State,
- Attachments
-
- switch.jpg (16.52 KiB) Viewed 424 times
Re: How to set up value open/close
2022, that's even 2 years ago
![Lachend :lol:](./images/smilies/icon_lol.gif)
Well, that's to be expected, your switch is called Door_sensor...nobody@all wrote: ↑29 Mar 2024, 00:18but in [switch#state#C] i have nothing.Code: Select all
on Door_sensor#State do Publish,homedoor_1,Door_sensor,State,[switch#state#C] endon
...
What I'am missing?
This should work:
Code: Select all
on Door_sensor#State do
Publish,homedoor_1,Door_sensor,State,[Door_sensor#state#C]
endon
/Ton (PayPal.me)
Re: How to set up value open/close
You might also need to use quotes as the " OPEN" has a space in it.
And you have too many commas for the MQTT topic.
Typically you have to use / as separator for topic levels.
Maybe this is better:
And you have too many commas for the MQTT topic.
Typically you have to use / as separator for topic levels.
Code: Select all
on Door_sensor#State do
Publish,homedoor_1/Door_sensor/State,"[Door_sensor#state#C]"
endon
Code: Select all
on Door_sensor#State do
if %eventvalue%=0
Publish,homedoor_1/Door_sensor/State,CLOSE
else
Publish,homedoor_1/Door_sensor/State,OPEN
endif
endon
-
- Normal user
- Posts: 30
- Joined: 09 Apr 2017, 23:27
Re: How to set up value open/close
I finally know why my wife is always angry at me - I think I'm doing it quickly but in real two year passed like a one day
this code
work great. thank You ![Lach :)](./images/smilies/icon_e_smile.gif)
![Erg Blij :D](./images/smilies/icon_e_biggrin.gif)
this code
Code: Select all
on Door_sensor#State do
if %eventvalue%=0
Publish,homedoor_1/Door_sensor/State,CLOSE
else
Publish,homedoor_1/Door_sensor/State,OPEN
endif
endon
![Lach :)](./images/smilies/icon_e_smile.gif)
Who is online
Users browsing this forum: No registered users and 33 guests