Pyhass / Hive-Custom-Component

A custom version of the home assistant hive component
MIT License
33 stars 17 forks source link

TRV battery sensors #4

Closed martinlong1978 closed 3 years ago

martinlong1978 commented 4 years ago

Hi. Will you be adding support for reporting battery status of TRVs?

Thanks

KJonline commented 4 years ago

@martinlong1978, yes the new upgrade which is in beta version should support TRV's battery status. I don't have a TRV myself so I wlill be looking for some testers to confirm this.

martinlong1978 commented 4 years ago

Excellent! I'll be glad to help.

On Sat, 10 Oct 2020, 23:39 Khole, notifications@github.com wrote:

@martinlong1978 https://github.com/martinlong1978, yes the new upgrade which is in beta version should support TRV's battery status. I don't have a TRV myself so I wlill be looking for some testers to confirm this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Pyhive/HA-Hive-Custom-Component/issues/4#issuecomment-706620975, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACJ7G2E774AJLKJE4OUQFLSKDPAXANCNFSM4SA5FDRA .

holdestmade commented 4 years ago

I have just tried the beta version (b7) and can confirm that battery levels for the TRVs are created. Unfortunately, the climate entities are not

martinlong1978 commented 4 years ago

I've been away, but hope to give it a try tonight.

On Mon, 19 Oct 2020, 12:35 holdestmade, notifications@github.com wrote:

I have just tried the beta version (b7) and can confirm that battery levels for the TRVs are created. Unfortunately, the climate entities are not

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Pyhive/HA-Hive-Custom-Component/issues/4#issuecomment-712096372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACJ7GZYZHMWZY6U6U3JUXLSLQP6LANCNFSM4SA5FDRA .

martinlong1978 commented 4 years ago

For me neither the climate entries, nor the battery entries are showing for the TRVs in the latest beta. Currently I need to stick with master to have a working system.

KJonline commented 3 years ago

@martinlong1978 please can you try beta 10 and feedback on the TRV issues

KJonline commented 3 years ago

Issue to be pick up in #10

martinlong1978 commented 3 years ago

As an aside, I see a problem in hotwater.py in pyhiveapi.

Many of the methods seem to take a device dict as a parameter, and then access the parameters of that dict (e.g. device["hive_id"] )

However, the parameters being passed into that method are the id themselves. Have a look at get_state and get_boost for example, and the places they are called from.

Regards

Martin

On Mon, 9 Nov 2020 at 10:50, Khole notifications@github.com wrote:

Closed #4.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

martinlong1978 commented 3 years ago

On the issue with the client devices... I was looking at the exception

Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform await asyncio.gather(pending) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities await asyncio.gather(tasks) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 361, in _async_add_entity suggested_object_id = entity.name File "/home/openhabian/.homeassistant/custom_components/hive/climate.py", line 107, in name return self.device["ha_name"] KeyError: 'ha_name'

So I put a debug line in climate.py (in the custom component)

2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] BathroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Den 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Dining Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Effies Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ensuite shower 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ethan's Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Hall 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Lounge Window 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Master Bedroom 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Office 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {}

So all those TRV devices have no attributes at all.

On Mon, 9 Nov 2020 at 21:45, Long, Martin martin@longhome.co.uk wrote:

As an aside, I see a problem in hotwater.py in pyhiveapi.

Many of the methods seem to take a device dict as a parameter, and then access the parameters of that dict (e.g. device["hive_id"] )

However, the parameters being passed into that method are the id themselves. Have a look at get_state and get_boost for example, and the places they are called from.

Regards

Martin

On Mon, 9 Nov 2020 at 10:50, Khole notifications@github.com wrote:

Closed #4.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

martinlong1978 commented 3 years ago

Hi,

I have found the problem, but I don't know the fix.

The issue is in get_heating in heating.py

The line: if device["device_id"] in Data.devices:

Taking, for example, my bathroom TRV... device_id 3fbed695-75cc-44f5-a6eb-7c50bbcd4cd4

However, in the dict Data.devices that object has the id: 945dc093-95a2-4c6f-bde2-d9724dfb56b2. The device_id is there in the object, under state/control

It looks like the object is laid out a bit differently to the thermostatui object. Please let me know if I can provide any additional information.

"945dc093-95a2-4c6f-bde2-d9724dfb56b2":{ "id":"945dc093-95a2-4c6f-bde2-d9724dfb56b2", "type":"trv", "sortOrder":1, "created":1572692038181, "parent":"c8b7142b-4812-4000-ae32-de2626e12a95", "props":{ "online":True, "presenceLastChanged":1604492001090, "model":"TRV001", "version":"0000021B", "manufacturer":"Danfoss", "upgrade":{ "available":False, "version":"0000021B", "progress":100, "upgrading":False, "status":"COMPLETE" }, "power":"battery", "signal":100, "battery":100, "eui64":"14B457FFFEC22F2F", "calibration":{ "start":"2019-11-02T16:19:36.988+0000", "end":"2019-11-02T19:50:37.115+0000" }, "capabilities":[ "INFORMATION", "RENAME", "DELETE", "TRV_CALIBRATION" ] }, "state":{ "name":"Bathroom", "control":"3fbed695-75cc-44f5-a6eb-7c50bbcd4cd4", "zone":"5977360b-9bb5-4b1f-915d-36e7bac2037f", "zoneName":"Thermostat 1", "childLock":False, "mountingMode":"HORIZONTAL", "mountingModeActive":False, "viewingAngle":"ANGLE_0", "calibrationStatus":"CALIBRATED" } },

On Mon, 9 Nov 2020 at 22:07, Long, Martin martin@longhome.co.uk wrote:

On the issue with the client devices... I was looking at the exception

Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform await asyncio.gather(pending) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities await asyncio.gather(tasks) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 361, in _async_add_entity suggested_object_id = entity.name File "/home/openhabian/.homeassistant/custom_components/hive/climate.py", line 107, in name return self.device["ha_name"] KeyError: 'ha_name'

So I put a debug line in climate.py (in the custom component)

2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] BathroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Den 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Dining Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Effies Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ensuite shower 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ethan's Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Hall 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Lounge Window 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Master Bedroom 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Office 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {}

So all those TRV devices have no attributes at all.

On Mon, 9 Nov 2020 at 21:45, Long, Martin martin@longhome.co.uk wrote:

As an aside, I see a problem in hotwater.py in pyhiveapi.

Many of the methods seem to take a device dict as a parameter, and then access the parameters of that dict (e.g. device["hive_id"] )

However, the parameters being passed into that method are the id themselves. Have a look at get_state and get_boost for example, and the places they are called from.

Regards

Martin

On Mon, 9 Nov 2020 at 10:50, Khole notifications@github.com wrote:

Closed #4.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

martinlong1978 commented 3 years ago

So... in hive_session.py line 339

        if Data.products[a_product]["type"] in Data.HIVE_TYPES["Heating"]:
            device_id = p["props"].get("zone", p["id"])
            device_name = p["state"].get("name", "Heating")
            for device in Data.devices:
                try:
                    if Data.devices[device]["type"] in

Data.HIVE_TYPES["Thermo"]: device = Data.devices[device] if p["parent"] == device["props"]["zone"]: device_id = device["id"] device_name = device["state"]["name"] break except: pass

this is getting the device id based on the zone. However, the TRVs don't match based on zone. However, for trvcontrol the trv device_id is right there in props/trvs[0]

  {
     "id":"776d3354-2923-446e-b5a4-ff190a0883a6",
     "type":"trvcontrol",
     "sortOrder":1,
     "created":1572692964145,
     "parent":"c8b7142b-4812-4000-ae32-de2626e12a95",
     "props":{
        "online":true,
        "version":"00000000",
        "upgrade":{
           "available":false,
           "upgrading":false
        },
        "parent":"776d3354-2923-446e-b5a4-ff190a0883a6",
        "capabilities":[
           "HOLIDAY_MODE",
           "BOOST",
           "TRV_AUTO_BOOST",
           "TRV_AUTO_BOOST_READY"
        ],
        "maxEvents":6,
        "pmz":"OK",
        "temperature":23.2,
        "working":false,
        "trvs":[
           "46184a71-3c43-45b1-b6cb-abb2c767222d"
        ],
        "previous":{
           "mode":"SCHEDULE"
        },
        "scheduleOverride":false,
        "zoneName":"Thermostat 1",
        "autoBoost":{
           "active":false,
           "target":22,
           "duration":30,
           "trvs":[
              "7d56c7c6-ed95-4856-a764-e303460e500b"
           ]
        }
     },

That said, my python isn't quite good enough to do the fix. I might have another look tomorrow, but I need to get the heating back online and go to bed.

On Mon, 9 Nov 2020 at 22:52, Long, Martin martin@longhome.co.uk wrote:

Hi,

I have found the problem, but I don't know the fix.

The issue is in get_heating in heating.py

The line: if device["device_id"] in Data.devices:

Taking, for example, my bathroom TRV... device_id 3fbed695-75cc-44f5-a6eb-7c50bbcd4cd4

However, in the dict Data.devices that object has the id: 945dc093-95a2-4c6f-bde2-d9724dfb56b2. The device_id is there in the object, under state/control

It looks like the object is laid out a bit differently to the thermostatui object. Please let me know if I can provide any additional information.

"945dc093-95a2-4c6f-bde2-d9724dfb56b2":{ "id":"945dc093-95a2-4c6f-bde2-d9724dfb56b2", "type":"trv", "sortOrder":1, "created":1572692038181, "parent":"c8b7142b-4812-4000-ae32-de2626e12a95", "props":{ "online":True, "presenceLastChanged":1604492001090, "model":"TRV001", "version":"0000021B", "manufacturer":"Danfoss", "upgrade":{ "available":False, "version":"0000021B", "progress":100, "upgrading":False, "status":"COMPLETE" }, "power":"battery", "signal":100, "battery":100, "eui64":"14B457FFFEC22F2F", "calibration":{ "start":"2019-11-02T16:19:36.988+0000", "end":"2019-11-02T19:50:37.115+0000" }, "capabilities":[ "INFORMATION", "RENAME", "DELETE", "TRV_CALIBRATION" ] }, "state":{ "name":"Bathroom", "control":"3fbed695-75cc-44f5-a6eb-7c50bbcd4cd4", "zone":"5977360b-9bb5-4b1f-915d-36e7bac2037f", "zoneName":"Thermostat 1", "childLock":False, "mountingMode":"HORIZONTAL", "mountingModeActive":False, "viewingAngle":"ANGLE_0", "calibrationStatus":"CALIBRATED" } },

On Mon, 9 Nov 2020 at 22:07, Long, Martin martin@longhome.co.uk wrote:

On the issue with the client devices... I was looking at the exception

Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform await asyncio.gather(pending) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities await asyncio.gather(tasks) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 361, in _async_add_entity suggested_object_id = entity.name File "/home/openhabian/.homeassistant/custom_components/hive/climate.py", line 107, in name return self.device["ha_name"] KeyError: 'ha_name'

So I put a debug line in climate.py (in the custom component)

2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] BathroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Den 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Dining Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Effies Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ensuite shower 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ethan's Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Hall 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Lounge Window 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Master Bedroom 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Office 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {}

So all those TRV devices have no attributes at all.

On Mon, 9 Nov 2020 at 21:45, Long, Martin martin@longhome.co.uk wrote:

As an aside, I see a problem in hotwater.py in pyhiveapi.

Many of the methods seem to take a device dict as a parameter, and then access the parameters of that dict (e.g. device["hive_id"] )

However, the parameters being passed into that method are the id themselves. Have a look at get_state and get_boost for example, and the places they are called from.

Regards

Martin

On Mon, 9 Nov 2020 at 10:50, Khole notifications@github.com wrote:

Closed #4.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

martinlong1978 commented 3 years ago

Hi,

I got this working by adding the following at hive_session.py line 352

            if Data.products[a_product]["type"] == "trvcontrol" :
                device_id = Data.products[a_product]["props"]["trvs"][0]

I would submit this as a pull request, but it feels like a massive hack to me. I'm sure there must be a better way of doing this. However, it got me up and running on the latest beta.

I couldn't seem to log in after deleting and recreating the integration on b18. However, i rolled back to b15 and could log in, and then roll forward to b18.

Hope this info is helpful

Martin

On Mon, 9 Nov 2020 at 23:54, Long, Martin martin@longhome.co.uk wrote:

So... in hive_session.py line 339

        if Data.products[a_product]["type"] in Data.HIVE_TYPES["Heating"]:
            device_id = p["props"].get("zone", p["id"])
            device_name = p["state"].get("name", "Heating")
            for device in Data.devices:
                try:
                    if Data.devices[device]["type"] in

Data.HIVE_TYPES["Thermo"]: device = Data.devices[device] if p["parent"] == device["props"]["zone"]: device_id = device["id"] device_name = device["state"]["name"] break except: pass

this is getting the device id based on the zone. However, the TRVs don't match based on zone. However, for trvcontrol the trv device_id is right there in props/trvs[0]

  {
     "id":"776d3354-2923-446e-b5a4-ff190a0883a6",
     "type":"trvcontrol",
     "sortOrder":1,
     "created":1572692964145,
     "parent":"c8b7142b-4812-4000-ae32-de2626e12a95",
     "props":{
        "online":true,
        "version":"00000000",
        "upgrade":{
           "available":false,
           "upgrading":false
        },
        "parent":"776d3354-2923-446e-b5a4-ff190a0883a6",
        "capabilities":[
           "HOLIDAY_MODE",
           "BOOST",
           "TRV_AUTO_BOOST",
           "TRV_AUTO_BOOST_READY"
        ],
        "maxEvents":6,
        "pmz":"OK",
        "temperature":23.2,
        "working":false,
        "trvs":[
           "46184a71-3c43-45b1-b6cb-abb2c767222d"
        ],
        "previous":{
           "mode":"SCHEDULE"
        },
        "scheduleOverride":false,
        "zoneName":"Thermostat 1",
        "autoBoost":{
           "active":false,
           "target":22,
           "duration":30,
           "trvs":[
              "7d56c7c6-ed95-4856-a764-e303460e500b"
           ]
        }
     },

That said, my python isn't quite good enough to do the fix. I might have another look tomorrow, but I need to get the heating back online and go to bed.

On Mon, 9 Nov 2020 at 22:52, Long, Martin martin@longhome.co.uk wrote:

Hi,

I have found the problem, but I don't know the fix.

The issue is in get_heating in heating.py

The line: if device["device_id"] in Data.devices:

Taking, for example, my bathroom TRV... device_id 3fbed695-75cc-44f5-a6eb-7c50bbcd4cd4

However, in the dict Data.devices that object has the id: 945dc093-95a2-4c6f-bde2-d9724dfb56b2. The device_id is there in the object, under state/control

It looks like the object is laid out a bit differently to the thermostatui object. Please let me know if I can provide any additional information.

"945dc093-95a2-4c6f-bde2-d9724dfb56b2":{ "id":"945dc093-95a2-4c6f-bde2-d9724dfb56b2", "type":"trv", "sortOrder":1, "created":1572692038181, "parent":"c8b7142b-4812-4000-ae32-de2626e12a95", "props":{ "online":True, "presenceLastChanged":1604492001090, "model":"TRV001", "version":"0000021B", "manufacturer":"Danfoss", "upgrade":{ "available":False, "version":"0000021B", "progress":100, "upgrading":False, "status":"COMPLETE" }, "power":"battery", "signal":100, "battery":100, "eui64":"14B457FFFEC22F2F", "calibration":{ "start":"2019-11-02T16:19:36.988+0000", "end":"2019-11-02T19:50:37.115+0000" }, "capabilities":[ "INFORMATION", "RENAME", "DELETE", "TRV_CALIBRATION" ] }, "state":{ "name":"Bathroom", "control":"3fbed695-75cc-44f5-a6eb-7c50bbcd4cd4", "zone":"5977360b-9bb5-4b1f-915d-36e7bac2037f", "zoneName":"Thermostat 1", "childLock":False, "mountingMode":"HORIZONTAL", "mountingModeActive":False, "viewingAngle":"ANGLE_0", "calibrationStatus":"CALIBRATED" } },

On Mon, 9 Nov 2020 at 22:07, Long, Martin martin@longhome.co.uk wrote:

On the issue with the client devices... I was looking at the exception

Traceback (most recent call last): File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform await asyncio.gather(pending) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities await asyncio.gather(tasks) File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 361, in _async_add_entity suggested_object_id = entity.name File "/home/openhabian/.homeassistant/custom_components/hive/climate.py", line 107, in name return self.device["ha_name"] KeyError: 'ha_name'

So I put a debug line in climate.py (in the custom component)

2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] BathroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Den 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] DenDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Dining Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Dining RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Effies Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Effies RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ensuite shower 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ensuite showerDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Ethan's Room 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Ethan's RoomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Hall 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] HallDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Lounge Window 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Lounge WindowDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Master Bedroom 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] Master BedroomDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {} 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeGetting heating data. 2020-11-09 22:03:30 ERROR (MainThread) [pyhiveapi.custom_logging] ERROR - No data found for device - Office 2020-11-09 22:03:30 DEBUG (MainThread) [pyhiveapi.custom_logging] OfficeDevice update {} 2020-11-09 22:03:30 ERROR (MainThread) [custom_components.hive.climate] Device: {}

So all those TRV devices have no attributes at all.

On Mon, 9 Nov 2020 at 21:45, Long, Martin martin@longhome.co.uk wrote:

As an aside, I see a problem in hotwater.py in pyhiveapi.

Many of the methods seem to take a device dict as a parameter, and then access the parameters of that dict (e.g. device["hive_id"] )

However, the parameters being passed into that method are the id themselves. Have a look at get_state and get_boost for example, and the places they are called from.

Regards

Martin

On Mon, 9 Nov 2020 at 10:50, Khole notifications@github.com wrote:

Closed #4.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

KJonline commented 3 years ago

Thanks @martinlong1978, I’ll update tonight and release a new beta. I appreciate your investigation into this it’s hard to debug I device I don’t physically have.