evcc-io / evcc

Sonne tanken ☀️🚘
https://evcc.io
MIT License
3.58k stars 661 forks source link

Add support for Shelly EM (2 channels) meter #4244

Closed efrencd closed 2 years ago

efrencd commented 2 years ago

Currently EVCC has a template for Shelly 3EM (3 channel Shelly Meter).

Theres is also a 2 channel cheaper model which is not included as a template in EVCC.

Product description in Shelly website. https://shelly.cloud/products/shelly-em-smart-home-automation-device/

It would be nice to add support for it.

Thanks!

andig commented 2 years ago

/cc @thierolm

VolkerK62 commented 2 years ago

@efrencd I use this also. You know, that you can use the http-plugin for integration?

efrencd commented 2 years ago

I didn't know. I'll try.

Anyway a direct integration with a template would be welcomed.

Thanks!

thierolm commented 2 years ago

Hi @efrencd , have U tested the shelly charger or shelly-pm1 meter template? U are able to define the channel in order to select P1 (channel = 0) or P2 (channel = 1) switch+meter ...

VolkerK62 commented 2 years ago

Hi @thierolm , I have Shelly EM in use. I tried shelly-1pm template. It doesn´t work.

- name: WP_power # Verbrauch (charger) Wärmepumpe
  type: template
  template: shelly-1pm
  host: 192.168.178.21
  channel: 1

result evcc meter

WP_power
--------
Power: invalid channel, missing power meter
VolkerK62 commented 2 years ago

So funktioniert es (custom)

- name: WP_power # Verbrauch (charger) Wärmepumpe
  type: custom
  power:         # Shelly EM Stromzange 2
    source: http
    uri: http://192.168.178.21/emeter/1
    jq: .power  
thierolm commented 2 years ago

Hi @VolkerK62 , could U pls provide me a trace log: evcc meter -l trace

VolkerK62 commented 2 years ago

@thierolm Here the template version:

pi@raspberrypi:~ $ evcc meter -l trace
[main  ] INFO 2022/08/31 09:16:30 evcc 0.100 (98d9a938)
[main  ] INFO 2022/08/31 09:16:30 using config file /etc/evcc.yaml
[shelly] TRACE 2022/08/31 09:16:31 GET http://192.168.178.21/shelly
[shelly] TRACE 2022/08/31 09:16:31 {"type":"SHEM","mac":"C45BBE77DE81","auth":false,"fw":"20220809-125130/v1.12-g99f7e0b","discoverable":true,"longid":1,"num_outputs":1,"num_meters":0,"num_emeters":2,"report_period":1}
WP_power
--------
[shelly] TRACE 2022/08/31 09:16:31 GET http://192.168.178.21/status
[shelly] TRACE 2022/08/31 09:16:31 {"wifi_sta":{"connected":true,"ssid":"KAS1","ip":"192.168.178.21","rssi":-52},"cloud":{"enabled":false,"connected":false},"mqtt":{"connected":false},"time":"09:16","unixtime":1661930190,"serial":16567,"has_update":false,"mac":"C45BBE77DE81","cfg_changed_cnt":0,"actions_stats":{"skipped":0},"relays":[{"ison":false,"has_timer":false,"timer_started":0,"timer_duration":0,"timer_remaining":0,"overpower":false,"is_valid":true,"source":"http"}],"emeters":[{"power":29.72,"reactive":35.57,"pf":0.64,"voltage":231.89,"is_valid":true,"total":226709.4,"total_returned":312236.8},{"power":1.56,"reactive":0.00,"pf":0.00,"voltage":231.89,"is_valid":true,"total":101094.1,"total_returned":0.5}],"update":{"status":"idle","has_update":false,"new_version":"20220809-125130/v1.12-g99f7e0b","old_version":"20220809-125130/v1.12-g99f7e0b"},"ram_total":51072,"ram_free":35868,"fs_size":233681,"fs_free":156373,"uptime":235549}
Power: invalid channel, missing power meter
VolkerK62 commented 2 years ago

Ahh, meter vs emeter?? "num_meters":0,"num_emeters":2

thierolm commented 2 years ago

Ahh, meter vs emeter?? "num_meters":0,"num_emeters":2

Jepp, da haben die Shelly Entwickler mal wieder nix von JSON Standardisierung gehalten ... :-(

@andig: Ich schau mal, dass ich am WE einen entsprechenden Erweiterungs-PR aufmache.

thierolm commented 2 years ago

@VolkerK62 + @efrencd Could U pls check test the PR? I do not have an Shelly EM device ...

VolkerK62 commented 2 years ago

Sorry, da hab ich absolut keine Ahnung, wie ich das machen könnte .... das hatten wir vor einiger Zeit schon mal ;-) Wenn andig es ins nightly nimmt, kann ich es gleich morgen früh testen.

andig commented 2 years ago

Ist drin

VolkerK62 commented 2 years ago

werd ich morgen mal testen. Aber vorher noch ne blöde Frage: nehm ich das Shelly-1pm Template oder hat es ein eigenes bekommen?

thierolm commented 2 years ago

nimm das Shelly-1pm template

VolkerK62 commented 2 years ago

@thierolm ist usage: pv optional oder zwingend? Ich nutze den Shelly EM als battery und als charge meter. Aktuell als custom ohne usage.

thierolm commented 2 years ago

Im Meter Template ist pv aktuell die einzige Option und muss so gesetzt werden. Du müsstest das so definierte Meter aber auch als battery meter in der evcc.yaml definieren können. Wenn du den Shelly als Charger nutzen willst, musst du das shelly Charger Template nehmen.

VolkerK62 commented 2 years ago

Top job. Funktioniert prima. Ich bin immer wieder erstaunt, was und wie schnell alles möglich ist ;-)

thierolm commented 2 years ago

Thx fürs Testen! Schönes WE!