sgupta999 / mqtt-bridge-smartthings

MQTT Bridge To SmartThings [MBS]
MIT License
27 stars 15 forks source link

Strange MQTT "translations" #24

Closed stofakiller closed 4 years ago

stofakiller commented 4 years ago

Im working with a tv light in ST with RGB.

I can turn i off in mqtt: smartthings/Tv/switch/cmd, payload off and i get MQTT --> ST - Topic: [smartthings/Tv/switch/cmd][off] [Tv][switch][off]

But when i want to turn it on it changes switch to level I send smartthings/Tv/switch/cmd, payload on, but i get MQTT --> ST - Topic: [smartthings/Tv/level/cmd][on] [Tv][level][on]

And of course it wont turn on

stofakiller commented 4 years ago

I found in mbs-server.js that switch on is converted to level, i changed it from level to switch, and now it works

                // If sending switch data and there is already a nonzero level value, send level instead
                // SmartThings will turn the device on
                if (property === 'switch' && contents === 'on' &&
                    history[topicLevelCommand] > 0) {
                    winston.info('Passing level instead of switch on');
                    property = 'switch';
                    contents = history[topicLevelCommand];
                }               
                postRequest(topic, contents, device, property, value, cmd, incoming);
sgupta999 commented 4 years ago

I am assuming you are using HASS.io and not devices.yml - thats the legacy implementation and I would not change it.

I would instead try to use devices.yml

stofakiller commented 4 years ago

but its the mqtt command response that is converted to level and not switch... No im not using hass.io, im using node red