jesserizzo / envoy_reader

MIT License
37 stars 26 forks source link

Improve detection of Envoy-S with consumption metering #4

Closed sfjes closed 5 years ago

sfjes commented 5 years ago

This small tweak fixes the check of the json length , which was causing a false negative on the detection of my Envoy-S with consumption metering. My Envoy-S returns two top sections, one for production and one for consumption.

$ curl -s http://envoy/production.json | jq length
2

This manifested as envoy_reader failing to pull my consumption data ("Consumption data not available for your Envoy device.") and was less transparent as it was reported in Home Assistant ("Unable to connect to Envoy. Check that the device is up at 'http://envoy'.").

I left it as a >=2 check since I'm unsure if other Envoy-S hardware revisions have different output. Has someone else confirmed they have a json response with 3 sections?

DavidDeSloovere commented 5 years ago

Just confirming: Works on my machine ;-) An original envoy C with production only.

image

sfjes commented 5 years ago

Rebased this PR on the current master. @jesserizzo any problem with merging it? Without it consumption meter reading is broken on my Envoy-S.

jesserizzo commented 5 years ago

@sfjes Sorry about that, I just never even saw this PR. I'll take a look at it this weekend.

jesserizzo commented 5 years ago

Sorry that took me 6 months. Looks great, thanks. And btw newer Envoys have a third section for storage, that's why it was === 3 originally.

sfjes commented 5 years ago

No worries! Thanks for merging it. My Envoy-S is capable of storage support but I'm guessing either it'd get a firmware update or need some flag enabled before it started reporting three sections (as I don't have any storage).