StyraHem / ShellyForHASS

Shelly smart home platform for Home Assistant
MIT License
616 stars 111 forks source link

[BUG] Total usage not updated after reload of integration for Shelly Plus 1PM #697

Open mflage opened 1 year ago

mflage commented 1 year ago

Environment

Describe the bug

After the initial reload of the integration I'm no longer able to get total usage (kwh) from the integration. If I reload the integration again, then it's updated. It basically doesn't look like it's updating subsequently over the websocket.

Steps to Reproduce

As above. I can force a reload of the integration and then I get the updated value.

Expected behavior

The total usage (kwh) should updated constantly.

Screenshots

N/A

Traceback/Error logs

After reloading the integration I can see the following json structure on the wire:

{"id":2,"src":"shellyplus1pm-a8032abe20e4","dst":"aios-140300976728976","result":{"ble":{"enable":false},"cloud":{"enable":false,"server":"iot.shelly.cloud:6012/jrpc"},"input:0":{"id":0, "name":null, "type":"switch", "invert":false,"factory_reset":true},"mqtt":{"enable":false,"server":null,"user":null,"pass":null,"topic_prefix":null,"rpc_ntf":true,"status_ntf":false},"switch:0":{"id":0, "name":"El-billader","in_mode":"follow","initial_state":"match_input", "auto_on":false, "auto_on_delay":60.00, "auto_off":false, "auto_off_delay": 60.00,"power_limit":3500},"sys":{"device":{"mac":"A8032ABE20E4","fw_id":"20210921-202918/0.8.1-g52de872"},"location":{"tz":"Europe/Oslo","lat":XXXXX,"lon":YYYY},"debug":{"mqtt":{"enable":false},"websocket":{"enable":false},"udp":{"addr":null}},"ui_data":{"consumption_types":["socket"]},"rpc_udp":{"dst_addr":null,"listen_port":null}},"wifi":{"ap":{"ssid":"ShellyPlus1PM-A8032ABE20E4","is_open":true, "enable":false},"sta":{"ssid":"xxxxxxxxxx","is_open":false, "enable":true, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"sta1":{"ssid":null,"is_open":true, "enable":false, "ipv4mode":"dhcp","ip":null,"netmask":null,"gw":null,"nameserver":null},"roam":{"rssi_thr":-80,"interval":60}}}}.~.p{"id":3,"src":"shellyplus1pm-a8032abe20e4","dst":"aios-140300976728976","result":{"ble":{},"cloud":{"connected":false},"input:0":{"id":0,"state":false},"mqtt":{"connected":false},"switch:0":{"id": 0, "source": "WS_in", "output": true, "apower": 1.532, "voltage": 231.273,"aenergy": {"total":329907.688},"temperature":{"tC":51.5, "tF":124.8}},"sys":{"mac":"A8032ABE20E4","restart_required":false,"time":"","unixtime":0,"uptime":1046917,"ram_size":249800,"ram_free":175020,"fs_size":414401,"fs_free":262044,"available_updates":{}},"wifi":{"sta_ip":"192.168.199.101","status":"got ip","ssid":"XXXXXXXXXXXX","rssi":-72}}}

Which has:

"aenergy": {"total":329907.688}

This contains the key "total", which currently is 329907.688.

Subsequent status messages from the Shelly Plus only shows the current power usage:

{"src":"shellyplus1pm-a8032abe20e4","dst":"aios-140300976728976","method":"NotifyStatus","params":{"ts":4618802.35,"switch:0":{"id":0,"apower":1.53}}}

Additional context

Maybe this is a bug with the Shelly websocket? And not the integration itself?