edekeijzer/OctoPrint-PSUControl-Shelly

Shell Plus 1PM will turn on, but the PSUControl-Shelly plugin does not seem to recognize its state.

Opened this issue · 3 comments

I am using the Shelly Cloud to operate my Shelly Plus 1PM. When I click on the lightning bolt icon at the top of Octoprint, the 1PM will change its state from off to on. However, the icon does not change to green, and the logs seem to indicate that even though Shelly Cloud is sending back the state of the device it is not being recognized.

Steps to reproduce the behavior:

  1. Click lightning bolt icon at the top of the Octoprint local webpage

Expected behavior
The device should come on (it does) but I am not able to turn it off because the device is not parsing an update on the current status from Shelly Cloud

Screenshots

Screenshot 2023-04-17 at 3 02 49 PM

Screenshot 2023-04-18 at 10 10 29 AM

Logs

2023-04-18 16:11:43,145 - octoprint.plugins.psucontrol - INFO - Switching PSU On
2023-04-18 16:11:43,145 - octoprint.plugins.psucontrol - DEBUG - Switching PSU On Using PLUGIN: psucontrol_shelly
2023-04-18 16:11:43,146 - octoprint.plugins.psucontrol_shelly - DEBUG - Switching PSU On
2023-04-18 16:11:43,159 - octoprint.plugins.psucontrol_shelly - DEBUG - PSUControl is using us for sensing
2023-04-18 16:11:46,216 - octoprint.plugins.psucontrol_shelly - DEBUG - url=https://shelly-68-eu.shelly.cloud/device/relay/control, status_code=200, text={"isok":true,"data":{"device_id":"b8d61a887eac"}}
2023-04-18 16:11:46,318 - octoprint.plugins.psucontrol - DEBUG - Polling PSU state...
2023-04-18 16:11:48,472 - octoprint.plugins.psucontrol_shelly - DEBUG - url=https://shelly-68-eu.shelly.cloud/device/status, status_code=200, text={"isok":true,"data":{"online":true,"device_status":{"mqtt":{"connected":false},"id":"b8d61a887eac","ble":[],"_updated":"2023-04-18 16:11:47","input:0":{"id":0,"state":false},"serial":1681834308.69,"switch:0":{"id":0,"apower":9.2,"source":"SHC","output":true,"voltage":122.1,"current":1.018,"aenergy":{"by_minute":[141.394,141.394,143.331],"minute_ts":1681834259,"total":9325.164},"temperature":{"tC":42.85,"tF":109.12}},"v_eve:0":{"ev":"","ttl":-1,"id":0},"cloud":{"connected":true},"wifi":{"sta_ip":"192.168.5.186","status":"got ip","ssid":"Internets-2.4","rssi":-79},"sys":{"available_updates":[],"mac":"B8D61A887EAC","restart_required":true,"time":"08:41","unixtime":1681742518,"uptime":918106,"ram_size":248828,"ram_free":137704,"fs_size":458752,"fs_free":98304,"cfg_rev":11,"kvs_rev":0,"schedule_rev":0,"webhook_rev":0},"ws":{"connected":false},"code":"SNSW-001P15UL"}}}
2023-04-18 16:11:48,473 - octoprint.plugins.psucontrol_shelly - ERROR - Unable to determine status. Check settings.
2023-04-18 16:11:48,473 - octoprint.plugins.psucontrol - DEBUG - isPSUOn: False
2023-04-18 16:11:53,478 - octoprint.plugins.psucontrol - DEBUG - Polling PSU state...
2023-04-18 16:11:54,676 - octoprint.plugins.psucontrol_shelly - DEBUG - url=https://shelly-68-eu.shelly.cloud/device/status, status_code=200, text={"isok":true,"data":{"online":true,"device_status":{"mqtt":{"connected":false},"id":"b8d61a887eac","ble":[],"_updated":"2023-04-18 16:11:48","input:0":{"id":0,"state":false},"serial":1681834309.69,"switch:0":{"id":0,"current":0.14,"source":"SHC","output":true,"apower":9.2,"voltage":122.1,"aenergy":{"by_minute":[141.394,141.394,143.331],"minute_ts":1681834259,"total":9325.164},"temperature":{"tC":42.85,"tF":109.12}},"v_eve:0":{"ev":"","ttl":-1,"id":0},"cloud":{"connected":true},"wifi":{"sta_ip":"192.168.5.186","status":"got ip","ssid":"Internets-2.4","rssi":-79},"sys":{"available_updates":[],"mac":"B8D61A887EAC","restart_required":true,"time":"08:41","unixtime":1681742518,"uptime":918106,"ram_size":248828,"ram_free":137704,"fs_size":458752,"fs_free":98304,"cfg_rev":11,"kvs_rev":0,"schedule_rev":0,"webhook_rev":0},"ws":{"connected":false},"code":"SNSW-001P15UL"}}}
2023-04-18 16:11:54,677 - octoprint.plugins.psucontrol_shelly - ERROR - Unable to determine status. Check settings.
2023-04-18 16:11:54,677 - octoprint.plugins.psucontrol - DEBUG - isPSUOn: False
2023-04-18 16:11:59,682 - octoprint.plugins.psucontrol - DEBUG - Polling PSU state...
2023-04-18 16:12:01,425 - octoprint.plugins.psucontrol_shelly - DEBUG - url=https://shelly-68-eu.shelly.cloud/device/status, status_code=200, text={"isok":true,"data":{"online":true,"device_status":{"mqtt":{"connected":false},"id":"b8d61a887eac","ble":[],"_updated":"2023-04-18 16:11:48","input:0":{"id":0,"state":false},"serial":1681834309.69,"switch:0":{"id":0,"current":0.14,"source":"SHC","output":true,"apower":9.2,"voltage":122.1,"aenergy":{"by_minute":[141.394,141.394,143.331],"minute_ts":1681834259,"total":9325.164},"temperature":{"tC":42.85,"tF":109.12}},"v_eve:0":{"ev":"","ttl":-1,"id":0},"cloud":{"connected":true},"wifi":{"sta_ip":"192.168.5.186","status":"got ip","ssid":"Internets-2.4","rssi":-79},"sys":{"available_updates":[],"mac":"B8D61A887EAC","restart_required":true,"time":"08:41","unixtime":1681742518,"uptime":918106,"ram_size":248828,"ram_free":137704,"fs_size":458752,"fs_free":98304,"cfg_rev":11,"kvs_rev":0,"schedule_rev":0,"webhook_rev":0},"ws":{"connected":false},"code":"SNSW-001P15UL"}}}
2023-04-18 16:12:01,426 - octoprint.plugins.psucontrol_shelly - ERROR - Unable to determine status. Check settings.
2023-04-18 16:12:01,427 - octoprint.plugins.psucontrol - DEBUG - isPSUOn: False

Just to be sure

  • Did you double check that the PSU Control - Shelly plugin is selected for Sensing as well as Switching in the PSU Control settings? Misconfiguration of this setting has been the cause of most of the reported issues. -Yes
  • Did you disable Auto-On in the PSU Control settings? This will cause erratic behaviour in the plugin and is not considered a bug since it cannot be resolved. -Yes

To be very sure

Did you read the previous paragraph and check the settings? From now on, these misconfigurations will be closed without further explanation. - Yes

Thanks for the clear debug logs. It appears you do get a reply from Shelly cloud but the plugin is unable to read the status from it. I'll look into it anytime soon.

Thanks so much!

Pulled your debug data through JSONLint:

{
	"isok": true,
	"data": {
		"online": true,
		"device_status": {
			"mqtt": {
				"connected": false
			},
			"id": "b8d61a887eac",
			"ble": [],
			"_updated": "2023-04-18 16:11:48",
			"input:0": {
				"id": 0,
				"state": false
			},
			"serial": 1681834309.69,
			"switch:0": {
				"id": 0,
				"current": 0.14,
				"source": "SHC",
				"output": true,
				"apower": 9.2,
				"voltage": 122.1,
				"aenergy": {
					"by_minute": [141.394, 141.394, 143.331],
					"minute_ts": 1681834259,
					"total": 9325.164
				},
				"temperature": {
					"tC": 42.85,
					"tF": 109.12
				}
			},
			"v_eve:0": {
				"ev": "",
				"ttl": -1,
				"id": 0
			},
			"cloud": {
				"connected": true
			},
			"wifi": {
				"sta_ip": "192.168.5.186",
				"status": "got ip",
				"ssid": "Internets-2.4",
				"rssi": -79
			},
			"sys": {
				"available_updates": [],
				"mac": "B8D61A887EAC",
				"restart_required": true,
				"time": "08:41",
				"unixtime": 1681742518,
				"uptime": 918106,
				"ram_size": 248828,
				"ram_free": 137704,
				"fs_size": 458752,
				"fs_free": 98304,
				"cfg_rev": 11,
				"kvs_rev": 0,
				"schedule_rev": 0,
				"webhook_rev": 0
			},
			"ws": {
				"connected": false
			},
			"code": "SNSW-001P15UL"
		}
	}
}

Apparently, the Cloud API output for the NG devices is quite different, my guess is that I'd need to use switch:0/output as status. Is it possible for you to use the local API (afaik that should be possible even when cloud API is enabled) because in all honesty I haven't done anything with this code in quite a while so I have to really look into this before I can fix it.