thirug010 / Virtual-Tasmota-for-Tuya-api-devices

New Tuya firmware (1.0.7, 2.0, 3.3..) updates disable the OTA Flashing options at the moment, This feature allows you to use the non flashed Tuya devices as tasmota device along with tasmota flashed devices, most of the tasmota features is virtually available and it can be expanded.
MIT License
16 stars 0 forks source link

MQTT commands must be lower case #4

Open wlatic opened 4 years ago

wlatic commented 4 years ago

Worked through a problem I had and found that the commands passed to Virtual Tasmota via MQTT must be lower case.

cmnd/bedroomlight/power1 ON (works) cmnd/bedroomlight/POWER1 ON (Doesn't)

It also appears that currently power1 ON toggles the light, just ad power1 OFF does. This means you can turn off the light (if it is on) using power1 ON.

This applies to dimmer and teleperiod, however RESULT and STATE are maintained as capitals.

thirug010 commented 4 years ago

I will have the option for case sensitive, as well working on the SetOption19 will post the update ASAP

thanks Thiru

wlatic commented 4 years ago

Really good work on this. Got the Home assistant config ready if you wanted to publish to the wiki.

The only issue I can really see now is:

It also appears that currently power1 ON toggles the light, just as power1 OFF does. This means you can turn off the light (if it is on) using power1 ON.

thirug010 commented 4 years ago

UPPER is to support the Tasmota MQTT setup working to support with and without case sensitive, Yes the it always toggle the status, I will post the update asap,

Please share or submit pull request on the Wiki for HA

Thanks

thirug010 commented 4 years ago

Pushed the changes,

  1. ON / OFF / Toggle Status
  2. use the config page and select Home Assistant ( setoptions19) will send the mqtt in lowercase
  3. later will enhance the same option to publish HA discovery topic

Check and let me know, any issue

Thanks Thiru

wlatic commented 4 years ago

The light still appears to be toggling when passing:

root@aml:~# mosquitto_pub -h 127.0.0.1 -t cmnd/bedroomlight/power1 -m OFF root@aml:~# mosquitto_pub -h 127.0.0.1 -t cmnd/bedroomlight/power1 -m OFF

Will check into the setoptions19 and autodiscovery by home assistant later tonight. Again great work with this, made it so much easier to do localtuya!

wlatic commented 4 years ago

Full run of the command and the output in debug console: command issued: mosquitto_pub -h 127.0.0.1 -t cmnd/bedroomlight/power1 -m OFF Light status currently on.

Jun-11-2019 8:36:22 AM Mqtt message device ID 1 Jun-11-2019 8:36:22 AM Utility.updateDevStatus --> setData: : {"multiple":true,"data":{"1":false}} Jun-11-2019 8:36:23 AM Data from device:: {"devId":"22025072b4e62d617dbf","dps":{"1":false},"t":1562808981} Jun-11-2019 8:36:23 AM called processData: for bedroomlight: {"devId":"22025072b4e62d617dbf","dps":{"1":false},"t":1562808981} Jun-11-2019 8:36:23 AM Publish Mqtt:: {"type":"Result","value":"{\"power1\" : \"OFF\"}","isHa":true,"nodeId":"bedroomlight","param":""} Jun-11-2019 8:36:23 AM Publish Mqtt:: {"type":"Power","value":"OFF","isHa":true,"nodeId":"bedroomlight","param":"1"}

To me this means your Virtual Tasmota isnt at fault but the tuyapi itself.

wlatic commented 4 years ago

Did you ever look into devices turning off and on when submitting just the power off?

thirug010 commented 4 years ago

@wlatic, Yes now the latest code has setoption 19 to send the mqtt in lowercase