kantlivelong / OctoPrint-PSUControl-Tasmota

Adds Tasmota Smart Plug support to OctoPrint-PSUControl as a sub-plugin
GNU Affero General Public License v3.0
8 stars 3 forks source link

Tasmota can't switch off #3

Open sigma415 opened 9 months ago

sigma415 commented 9 months ago

PSU_Tasmota plugin cannot switch off, when using sense = Tasmota. (only switch on) PSU control icon remains grey after switch on and toggle has no effect Plug uses Tasmota 12.2.0

If I change to sense = Internal I can switch on AND off

In log I get: 2023-12-19 13:39:29,998 - octoprint.plugins.psucontrol_tasmota - ERROR - Unable to determine status. Check settings. 2023-12-19 13:39:35,306 - octoprint.plugins.psucontrol_tasmota - DEBUG - cmd=Status 0, status_code=200, text={"Status":{"Module":0,"DeviceName":"Plug_NOUS_A1_03","FriendlyName":["Plug_NOUS_A1_03"],"Topic":"DVES_5D834D","ButtonTopic":"0","Power":1,"PowerOnState":1,"LedState":1,"LedMask":"FFFF","SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0,"InfoRetain":0,"StateRetain":0,"StatusRetain":0},"StatusPRM":{"Baudrate":115200,"SerialConfig":"8N1","GroupTopic":"tasmotas","OtaUrl":"http://ota.tasmota.com/tasmota/release/tasmota.bin.gz","RestartReason":"External System","Uptime":"0T01:47:41","StartupUTC":"2023-12-19T10:51:53","Sleep":50,"CfgHolder":4617,"BootCount":18,"BCResetTime":"2022-11-12T14:03:14","SaveCount":119,"SaveAddress":"FA000"},"StatusFWR":{"Version":"12.2.0(tasmota)","BuildDateTime":"2022-10-17T08:39:23","Boot":31,"Core":"2_7_4_9","SDK":"2.2.2-dev(38a443e)","CpuFrequency":80,"Hardware":"ESP8285","CR":"398/699"},"StatusLOG":{"SerialLog":2,"WebLog":2,"MqttLog":0,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["WLAN-Schaut",""],"TelePeriod":60,"Resolution":"558180C0","SetOption":["04208009","2805C80001000600003C5A0A002800000000","000000C8","00006000","00004000","00000000"]},"StatusMEM":{"ProgramSize":626,"Free":376,"Heap":23,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"144051","FlashFrequency":40,"FlashMode":"DOUT","Features":["00000809","8F9AC787","04368001","000000CF","010013C0","C000F981","00004004","00001000","54000020","00000000"],"Drivers":"1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37,45,62","Sensors":"1,2,3,4,5,6"},"StatusNET":{"Hostname":"DVES-5D834D-0845","IPAddress":"192.168.56.189","Gateway":"192.168.56.100","Subnetmask":"255.255.255.0","DNSServer1":"192.168.56.100","DNSServer2":"0.0.0.0","Mac":"70:03:9F:5D:83:4D","Webserver":2,"HTTP_API":1,"WifiConfig":4,"WifiPower":17.0},"StatusMQT":{"MqttHost":"192.168.56.143","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_5D834D","MqttUser":"DVES_USER","MqttCount":1,"MAX_PACKET_SIZE":1200,"KEEPALIVE":30,"SOCKET_TIMEOUT":4},"StatusTIM":{"UTC":"2023-12-19T12:39:34","Local":"2023-12-19T13:39:34","StartDST":"2023-03-26T02:00:00","EndDST":"2023-10-29T03:00:00","Timezone":99,"Sunrise":"08:39","Sunset":"16:54"},"StatusPTH":{"PowerDelta":[0,0,0],"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0},"StatusSNS":{"Time":"2023-12-19T13:39:34","ENERGY":{"TotalStartTime":"2022-11-12T14:03:14","Total":39.592,"Yesterday":0.549,"Today":0.034,"Power":20,"ApparentPower":37,"ReactivePower":31,"Factor":0.54,"Voltage":233,"Current":0.157}},"StatusSTS":{"Time":"2023-12-19T13:39:34","Uptime":"0T01:47:41","UptimeSec":6461,"Heap":23,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":24,"MqttCount":1,"POWER1":"on","Wifi":{"AP":1,"SSId":"WLAN-Schaut","BSSId":"CC:CE:1E:2A:AF:E6","Channel":11,"Mode":"11n","RSSI":42,"Signal":-79,"LinkCount":1,"Downtime":"0T00:00:06"}}}

kantlivelong commented 9 months ago

Thanks for the info. I'm not sure why the status is being reported in lower case but easy enough to work around. Can you try downloading a zip for the fix_issue_3 branch, install, test, and report back?

ZIP URL: https://codeload.github.com/kantlivelong/OctoPrint-PSUControl-Tasmota/zip/refs/heads/fix_issue_3

sigma415 commented 9 months ago

Thanks a lot. WIth your fix_issue_3 it works as expected :) Maybe there was a change in Tasmota some versions before ?

Maybe there's also a relation to this PR ? : https://github.com/kantlivelong/OctoPrint-PSUControl-Tasmota/pull/2

kantlivelong commented 9 months ago

I checked with someone running the latest version of Tasmota and it still reports values in uppercase. Maybe it's an option hiding somewhere?

sigma415 commented 9 months ago

After some investigation I can answer your question: Yes, there is a (very) hidden option in Tasmota under MQTT commands.

2023-12-20_16h41_59

https://tasmota.github.io/docs/Commands/#mqtt

I did not use this option by intention but in fact my state texts are changed to lowercase on, off, toggle, hold ;( I have also enabled MQTT in my Tasmota devices to be able to use them in my FHEM environment. And FHEM provides some "mysterious" templates to integrate Tasmota MQTT devices. Maybe these templates made the changes ? :( In addition I found in web some discussions, that people using Home Assistant or openHAB also seem to have some problems with upper or lower case with Tasmota.

Would it be a problem, if you change the query in your plugin to case insensitive ? In Tasmota console I can use everything: ON, on, 1, OFF, off, 0, TOGGLE, toggle ... Thank you.

kantlivelong commented 9 months ago

Ah! Confirmed from my end.

I'll keep this branch as is for now but will likely add an advanced option to define these in the future.