Mads_Bloch
(Mads Bloch)
February 6, 2020, 4:04pm
1
Hi have have some problem regarding the commands sent from openhab to device.
i have tried for a couple of days to fix the problem without luck
Im running openhabian 2.5.1 fresh install on a RPI3B
The problem is that i have a switch item that sents “1” and “0” instead of “ON” and “OFF”
Things:
Type switch : Hus_1sal_bad_udsug "Tænd udsugning i badeværelse" [ stateTopic="hjem/1/badeværelse/fancontrol/fan_sta", commandTopic="hjem/1/badeværelse/fancontrol/fan_cmd" ]
Type switch : Hus_1sal_bad_udsug_speed "Speed udsugning i badeværelsee" [ stateTopic="hjem/1/badeværelse/fancontrol/fanspeed_sta", commandTopic="hjem/1/badeværelse/fancontrol/fanspeed_cmd" ]
Items:
Switch Fan1Power "Ventilator power" <fan> (Fan_F_Badevarelse, F) {channel="mqtt:topic:mosquitto:homemadeMQTT:Hus_1sal_bad_udsug"}
Switch Fan1Speed "Ventilator high/low" <flow> (Fan_F_Badevarelse, F) {channel="mqtt:topic:mosquitto:homemadeMQTT:Hus_1sal_bad_udsug_speed"}
From mqtt explorer, here you can see that the
fanspeed_cmd=1 it should be =ON
fan_cmd=1 it should be=ON
‘’
Thanks Mads
H102
(CM6.5 H102)
February 6, 2020, 4:08pm
2
Try using MAP transformation on the Thing.
Example:
Thing topic Esp1 "Garage Light Level" @ "Garage" {
Channels:
Type number : level "Light Level" [ stateTopic="/Esp1/Garage/LightLevel" ]
Type switch : contact "Open Closed" [ stateTopic="/Esp1/Door/Switch", transformationPattern="MAP:ONOFF.map" ]
Type switch : motion "Motion" [ stateTopic="/Esp1/Motion/Switch", transformationPattern="MAP:ONOFF.map" ]
}
Don’t forget to install the transformation service via PaperUI and put the transformation on the command topic to send a command.
Here is the map file for the things above:
ONOFF.map
GPIO,13,1=ON
GPIO,13,0=OFF
1=ON
0=OFF
You shouldn’t need the GPIO part just the last two lines.
rlkoshak
(Rich Koshak)
February 6, 2020, 4:11pm
3
There is an easier way from using the map transform. There is an onState and offState (or something like that) which you can define on the Channel which does essentially the same thing that the map transform does. I don’t use .things files so I’m not sure how that translates to the .things files but you should be able to search around the forum and find examples.
H102
(CM6.5 H102)
February 6, 2020, 4:16pm
4
I should probably use PaperUI to create a Thing or two just to help others on the forum as I’m still 100% files…and per my wife hardheaded.
2 Likes
Mads_Bloch
(Mads Bloch)
February 6, 2020, 6:06pm
5
I tried making a ONOFF.map file with
1=ON
0=OFF
there was a little change i the behavior, now im able, after many tries to change fan_cmd=0 and back to fan_cmd=1
New version things file:
Type switch : Hus_1sal_bad_udsug "Tænd udsugning i badeværelse" [ stateTopic="hjem/1/badeværelse/fancontrol/fan_sta", commandTopic="hjem/1/badeværelse/fancontrol/fan_cmd", transformationPattern="MAP:ONOFF.map" ]
Type switch : Hus_1sal_bad_udsug_speed "Speed udsugning i badeværelsee" [ stateTopic="hjem/1/badeværelse/fancontrol/fanspeed_sta", commandTopic="hjem/1/badeværelse/fancontrol/fanspeed_cmd", transformationPattern="MAP:ONOFF.map" ]
Mqtt explorer
Thanks Mads
1 Like
Mads_Bloch
(Mads Bloch)
February 6, 2020, 6:45pm
6
I have tried
transformationPattern=“MAP:ONOFF.map”
transformationPatternOut=“MAP:ONOFF.map”
i will tried
formatBeforePublish
H102
(CM6.5 H102)
February 6, 2020, 6:59pm
7
For the first switch did you try:
Type switch : Hus_1sal_bad_udsug "Tænd udsugning i badeværelse" [ stateTopic="hjem/1/badeværelse/fancontrol/fan_sta", commandTopic="hjem/1/badeværelse/fancontrol/fan_cmd", on="ON", off="OFF" ]
And add to the map file for the other channels:
1=ON
0=OFF
OFF=0
ON=1
I also just noticed on the screen shot this is zigbee2mqtt. Have you added:
experimental:
output: 'json'
to the bottom of your ymal file?
Mads_Bloch
(Mads Bloch)
February 6, 2020, 7:19pm
8
Hi
I have not tried , on=“ON”, off=“OFF” but i have tried 1=“ON”, 0=“OFF”
The fan_cmd and fanspeed_cmd is a WIFI connect device
I the zigbee2mqtt ymal file is completely standard, i just installed it yesterday, i only have one device pair with it
H102
(CM6.5 H102)
February 6, 2020, 7:23pm
9
Looking at the screen shot the only thing that uses ON/OFF is the fans status e.g. fan_sta and fanspeed_sta
You need to control the fan by turning it on with 0=OFF and 1=ON.
To control the speed you also need a number, or something different e.g. HIGH, LOW ?? In the pic it looks like you need a number.
Mads_Bloch
(Mads Bloch)
February 6, 2020, 7:28pm
10
HI
Its working
i tried this , on=“ON”, off=“OFF”
at first it only worked on fan_cmd but after a reboot its also working on fanspeed_cmd
Type switch : Hus_1sal_bad_udsug "Tænd udsugning i badeværelse" [ stateTopic="hjem/1/badeværelse/fancontrol/fan_sta", commandTopic="hjem/1/badeværelse/fancontrol/fan_cmd", on="ON", off="OFF" ]
i did not now that it would sent a “1” instead of “ON” because of the differens between on and ON ??
but
THANKS
H102
(CM6.5 H102)
February 6, 2020, 7:32pm
11
Mads_Bloch:
Its working
Yea.
H102:
For the first switch did you try:
Type switch : Hus_1sal_bad_udsug "Tænd udsugning i badeværelse" [ stateTopic="hjem/1/badeværelse/fancontrol/fan_sta", commandTopic="hjem/1/badeværelse/fancontrol/fan_cmd", on="ON", off="OFF" ]
I posted that earlier but honestly thought you had tried that already.
Please click the square box on the solution post to mark topic as solved.
Mads_Bloch
(Mads Bloch)
February 6, 2020, 7:32pm
12
I have made the “fan controller” my self, it just need ON and OFF