PhilipJonasFranz / Shelly-PDU

A remote power monitoring tool building on Shelly Plug S smart switches.
Apache License 2.0
15 stars 1 forks source link

Support for shelly plug 2? #1

Open dominch opened 2 weeks ago

dominch commented 2 weeks ago

hello, I could not run this app with shelly plug 2, it seems to be bigger, maybe more advanced option.

image

App seems to connect with some messages, others give 500 :(

BTW: readme link to shelly site is not valid now

PhilipJonasFranz commented 2 weeks ago

Hi,

since I don't have this device I cannot reproduce the problem. Could you be more specific which calls fail?

Maybe I can figure out the issue looking at the API docs.

dominch commented 2 weeks ago

device is configured as 192.168.201.45 from logs:

shelly-pdu-ingress   | Serving from API endpoint: http://shelly-pdu-backend:5000/proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0
shelly-pdu-backend   | 172.20.0.5 - - [22/Oct/2024 11:07:49] "GET /proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0 HTTP/1.1" 500 -
shelly-pdu-ingress   | GET /api/proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0 500 144.796 ms - 59
shelly-pdu-ingress   | Serving from API endpoint: http://shelly-pdu-backend:5000/hosts
shelly-pdu-backend   | 172.20.0.5 - - [22/Oct/2024 11:07:51] "GET /hosts HTTP/1.1" 200 -
shelly-pdu-ingress   | GET /api/hosts 200 33.475 ms - 191
shelly-pdu-ingress   | Serving from API endpoint: http://shelly-pdu-backend:5000/proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0
shelly-pdu-backend   | 172.20.0.5 - - [22/Oct/2024 11:07:51] "GET /proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0 HTTP/1.1" 500 -
shelly-pdu-ingress   | GET /api/proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0 500 143.189 ms - 59
shelly-pdu-ingress   | Serving from API endpoint: http://shelly-pdu-backend:5000/hosts
shelly-pdu-backend   | 172.20.0.5 - - [22/Oct/2024 11:07:53] "GET /hosts HTTP/1.1" 200 -
shelly-pdu-ingress   | GET /api/hosts 200 34.245 ms - 191
shelly-pdu-ingress   | Serving from API endpoint: http://shelly-pdu-backend:5000/proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0
shelly-pdu-backend   | 172.20.0.5 - - [22/Oct/2024 11:07:53] "GET /proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0 HTTP/1.1" 500 -
shelly-pdu-ingress   | GET /api/proxy?url=http://192.168.201.45/rpc/Switch.GetStatus?id=0 500 138.742 ms - 59
shelly-pdu-ingress   | Serving from API endpoint: http://shelly-pdu-backend:5000/average_power
shelly-pdu-backend   | 172.20.0.5 - - [22/Oct/2024 11:07:54] "GET /average_power HTTP/1.1" 200 -

seems that /rpc/ returns 404 but, there is some response on /status link:

{"wifi_sta":{"connected":true,"ssid":"MyWiFi","ip":"192.168.201.45","rssi":-59},"cloud":{"enabled":true,"connected":true},"mqtt":{"connected":false},"time":"13:13","unixtime":1729595589,"serial":12059,"has_update":false,"mac":"E8DB84D9D21A","cfg_changed_cnt":6,"actions_stats":{"skipped":0},"relays":[{"ison":true,"has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"overpower":false,"source":"input"}],"meters":[{"power":8.29,"overpower":0.00,"is_valid":true,"timestamp":1729602789,"counters":[8.210, 8.195, 8.182],"total":73136}],"update":{"status":"idle","has_update":false,"new_version":"20230913-113610/v1.14.0-gcb84623","old_version":"20230913-113610/v1.14.0-gcb84623","beta_version":"20231107-164401/v1.14.1-rc1-g0617c15"},"ram_total":52096,"ram_free":39868,"fs_size":233681,"fs_free":164656,"uptime":537447}
PhilipJonasFranz commented 1 week ago

I did some initial investigation, and it looks like the Shelly Plug 2 is a Gen 1 device, while the Shelly Plug S is a Gen 2 device. It looks like Gen 1 devices dont support RPC calls, but only simple HTTP requests.

The backend currently proxies the RPC calls, which isnt very elegant. Do support other devices such as Gen 1 devices, a larger refactor will be required sadly, to support both RPC and HTTP calls.

As stated in the other issue, im currently studying for exams, but i hope to get back to this afterwards.

Edit: i have added a note to the readme stating currently supported devices to prevent confusion in the future.