openmotics / home-assistant

OpenMotics Home Assistant integration Beta
GNU Affero General Public License v3.0
15 stars 9 forks source link

Energy sensors not detected when using cloud #14

Closed tmds closed 1 year ago

tmds commented 2 years ago

I've just installed home assistant with the openmotics integration. This went really smooth. Nice job!

The energy sensors are not showing up.

When I use the cloud.openmotics.com site, I see this:

get_power_modules returns:

{"modules": [{"input2": "CV_3", "input3": "PK", "input0": "DM", "input1": "H_1", "input6": "", "input7": "", "input4": "Vent", "input5": "Was", "times0": "", "times1": "", "input8": "", "input9": "H_2", "times4": "", "times5": "", "times6": "", "times7": "", "sensor9": 3, "sensor8": 2, "inverted10": true, "inverted11": true, "sensor1": 3, "sensor0": 3, "sensor3": 3, "sensor2": 3, "sensor5": 3, "sensor4": 3, "sensor7": 2, "sensor6": 2, "sensor11": 3, "sensor10": 3, "id": 2, "version": 12, "times2": "", "times3": "", "address": "E2", "times10": "", "times11": "", "name": "", "inverted8": false, "inverted9": true, "inverted4": true, "inverted5": false, "inverted6": false, "inverted7": false, "inverted0": true, "inverted1": false, "inverted2": false, "inverted3": true, "input10": "WP", "input11": "SP", "times9": "", "times8": ""}], "success": true}

get_realtime_power returns:

{"2": [[234.9828948975, 49.9997138977, -0.0022277292, -1.3940269947], [234.9828948975, 49.9997138977, 1.6432694197, 242.5885620117], [234.9546813965, 49.9997138977, 0.0191395469, -0.8579273224], [234.9546813965, 49.9997138977, 0.3793674707, 41.1819381714], [234.7076263428, 49.9997138977, 0.1687311381, 11.6792593002], [234.7076263428, 49.9997138977, -0.0003759707, 0.257691741], [234.6019744873, 49.9997138977, -0.0024420517, 0.1721440256], [234.6019744873, 49.9997138977, -0.0021899438, 0.1540243328], [234.025177002, 49.9997138977, -0.0049682073, -0.076439485], [234.025177002, 49.9997138977, 0.9160497189, -25.5000915527], [234.0469970703, 49.9997138977, 0.0782366022, 6.8641223907], [234.0469970703, 49.9997138977, 0.1229901835, 4.7641849518]], "success": true}

@kneirinck @woutercoppens do you have an idea why this isn't working, or some advice on how to debug this?

woutercoppens commented 2 years ago

Hi tom, It is possible that it is not yet implemented. My installation doesn't have the energy sensors, so I didn't have anything to test with.

tmds commented 2 years ago

I verified my installation includes the changes from https://github.com/openmotics/home-assistant/pull/13, so I think the sensors should show up.

kneirinck commented 2 years ago

13 exposes energy sensors but it depended on https://github.com/openmotics/pyhaopenmotics/pull/130 which got included but that only supports energy sensors when using the local gateway setup I'm afraid.

It does not support it using the cloud setup but feel free to implement it :)

tmds commented 2 years ago

I tried switching to local mode. The integration tab shows Retrying setup: 127.

The log file has a stacktrace:

2022-10-14 13:13:25.430 ERROR (MainThread) [custom_components.openmotics.coordinator] Unexpected error fetching Localgw_192.168.1.106 data: 127
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/openmotics/coordinator.py", line 53, in _async_update_data
    my_outputs = await self._omclient.outputs.get_all()
  File "/config/deps/lib/python3.10/site-packages/pyhaopenmotics/openmoticsgw/outputs.py", line 71, in get_all
    outputs = [Output.from_dict(device) for device in data]
  File "/config/deps/lib/python3.10/site-packages/pyhaopenmotics/openmoticsgw/outputs.py", line 71, in <listcomp>
    outputs = [Output.from_dict(device) for device in data]
  File "/config/deps/lib/python3.10/site-packages/pyhaopenmotics/openmoticsgw/models/output.py", line 86, in from_dict
    output_type = OPENMOTICS_OUTPUT_TYPE_TO_NAME[data.get("type", 0)]
KeyError: 127
tmds commented 2 years ago

I've added 127: "UNKNOWN", to OPENMOTICS_OUTPUT_TYPE_TO_NAME and it's up and running now! Including energy sensors!

tmds commented 2 years ago

With the change to local mode, all temperature sensors and humidity sensors are reporting 0.

Maybe pyhaopenmotics doesn't support those in local mode?

I don't have a use-case for those sensors, so I don't mind them not working for now. When I do, I'll take a closer look.