Hive Heating UK

Hi @Khole,

First off, I like a lot how you have integrated your light code in to the existing code, it fits in really well.

I am looking through some stuff now to see if I can help with the command failing.
Is there anything output in the log in HA to indicate an error?

What I tend to do when it does not work, I turn on a lot of outputting of states and any catch errors to the logger so it appears in the HA Info log, so we might need to do that if there is nothing already in the log

Hi @rendili

Thanks a lot for looking over the changes, I am not seeing any errors in the logs but I have found a conversation on the HA github page saying that after v0.36, there is a supported features property required in the light platform to activate the brightness here is the link https://github.com/home-assistant/home-assistant/issues/5428.

How do you enable the outputting and detailed logging for states as you mentioned in your previous post?

I am away at the minute so I am planning to have another attempt on Friday at getting the brightness and light switch on working.

Thanks
Khole

Hi @Khole,

I just add a load of comments and variable values to the logger to see what is going on at key points. So to check what brightness is being passed to the turn_on method I would add :
_LOGGER.error("Hive Light turn_on - NewBrightness : %s", NewBrightness)

to the code just before it called the main hive code so it output to the HA log the value.

I have changed a bit of code in your Hive_Lights.yaml (2.6 KB) file.
(sorry quick edit. meant to say that I only modified slightly the “def turn_on” and “def supported_features” sections)

This may enable the brightness slider and may even fix the error with any luck. Flying blind though as I dont have any lights :slight_smile:

If that does not work we need to add more logging to see exactly what the error is and where and possibly outputting the node attributes returned for when the light it on and also when the light is off.

I was also thinking, that this code, along with the climate and sensor, will only allow one of each type, so we would need to update a fair bit to allow for more than one light for example and more than one heating zone.
The trouble is I would need to see all the node JSON output from Hive for a setup with more than one device of each different device type.
Isnt there also three different light models that you could have on hive, so ideally we would need to detect and cater for each model.

Hi @rendili

Thanks for that, I will give it a go on Friday, one thing I have noticed about the brightness function in HA is the measurement is 1 - 255, but the value hive stores for brightness is a percentage so I think we are going to have to convert the value retrieved from HA into percentage. This part is not really an issue we can just divide the value retrieved from HA by 255 then times it by 100. The issue we might have is hive sets brightness at percentages in multiples of 5 E.G( 5%, 10%, 15%, 20%). So I need to find a way of rounding up the percentage to the nearest 5 E.G( 82% rounded up to 85%). I don’t need to send it with a percentage sign I just put it in the example for illustration.

As you mentioned there are 3 lights which hive can provide and this will only work for hive basic light with just brightness. When I get around to purchasing more lights I will probably get the new types so I could look at adapting the light platform more then.

You mentioned about upgrading it to work with multiple lights, I was thinking about this yesterday could we pass the hive names into the platform and use the hive device name for the device in HA? Then some how (not sure if possible) retrieve the friendly name when actioning something a switch on or set temperature, passing it into the hive main component and finding the I’d based on the name passed through (all hypertheical not sure if it could work)

Thanks
Khole

Hi guys
Just trying now to update my boolean scripts for Hive. I used to use the following script to turn the boolean value on or off based on the current state of climate.hive_heating:

alias: Hive boolean off
trigger:
  - platform: state
    entity_id: climate.hive_heating
    from: 'SCHEDULE'
    to: 'OFF'
action:
  - service: homeassistant.turn_off
    entity_id: input_boolean.hive_schedule

Obviously this now doesn’t work as the state climate.hive_heating displays the current temperature and not SCHEDULE or OFF. Can we change this, as we already have the current temp as a sub component? Or do you know how I can easily change the above to look for climate.hive_heating.operation_mode=SCHEDULE?

Thanks

EDIT: OK found it myself :slight_smile: changed it to

alias: Hive boolean off
trigger:
  - platform: state
    entity_id: sensor.hive_heating_mode
    from: 'SCHEDULE'
    to: 'OFF'
action:
  - service: homeassistant.turn_off
    entity_id: input_boolean.hive_schedule
1 Like

Hi @gr4z,

Glad that you got it working, and all this will help me a lot when I get round to using some presence based automation on my heating, thanks :slight_smile:

I must admit though, I don’t know why what you changed it to would work as the sensor entities are only to show what is going on with the system, such as the current modes, boosts and temperatures and don’t have any methods to make changes. Whilst the climate devices (heating and hotwater) both have methods to change the mode and heating to change the temperature.

Also, nothing should have changed with the latest version with this regard, the only thing I changed was adding a couple of state attributes to display when the target temperature and mode changed.
But as you mentioned the hive_heating does return current temperature as its state, which on reflection does not make sense, I can easily change this to the heating mode as suggested,
I have been a bit busier than normal the last week, but hopefully some time next week I am hoping to post an updated version which has a couple of bits I am working on, I will include the current state change in that. Does that change sounds ok?

Hi @Khole,

With regards to the brightness, all this is possible, just a matter of how much code :slight_smile:
I did not know the Hive lights work with a 5% increment percentage, my only exposure to the Hive lights is from what you have told me, all a good learning experience :slight_smile:

To support all the Hive light models I am hoping this could be handled with just an expanded version of what you have already and the method that gets the different nodes can detect each model somehow and then this is passed to the light device and it handles things accordingly. I think the last bit should be straight forward, it is just a matter of detection the light model, hopefully with something as simple as a different nodetype :slight_smile:

For the multiple devices of the same type, I think maybe for lights, plugs and sensors this could be more simple as they should all hang off from the one hub, but for heating and hotwater I have a feeling that they need to relate in to child and parent devices for each heating / hotwater zone, so this could be more complex to support. for example the receiver, thermostat, heating device and hotwater device I think all group together to form one zone and hang off the hub as child devices. I would need to look at the detail on my setup for my one zone, I had a brief look but not long enough to get a complete understanding.
For all devices / nodes though, already the code (including your new light code) gets all devices, even if 10 lights for example, and adds them to the correct node type dictionary type. The limitation at the moment is that the code always only uses the first device in each node type. As you say we need to pass an identifier, I think this should be the NodeID as this will be unique, and this should be used to pass to all the methods to get data and set data and add devices. I don’t know though what could be used as the unique, more friendly name in HA to identify and also as a nice displayname.
I am sure though, that when we switch to this new way of working, if we are not careful (and I have the start of an idea for this ) it could break all automations and configurations already setup for the current version.

I think after my current changes (and hopefully adding your new light code in to the changes also) I will work on the multiple device thing, its been on my list of things I wanted to work on for a while now. I just cant test any of it as I only have one. It would be great to have some testers with a load of lights, plugs, sensors and a couple of hotwater / heating zones :smile:

Looking forward to your test on Friday :slight_smile:

I use the sensor along with a Boolean to allow me to change the heating using Apple Homekit and/or Siri. When I am driving home after work the heating has been off all day. Rather than rely on location based triggers from miles away, I just say ‘hey siri turn the heating on’.

If I forget then the Wifi location trigger will enable the heating in any case when I get home and get a wifi connection.

Hi @gr4z

Do you use Siri to switch on/off the hive heating climate device? What setup do you have to enable this I can get hombridge to identify the climate device using the home assistant-homebridge plugin, but the only functionality that seems to work for me is setting the temprature. If I set the mode to “off” in HomeKit it reverts back to the previous setting.

Please could you share some of your config and how you have achieved this?

Mmm it seems stuff is broken again :frowning: when I manually change the heating status in the Hive app from Schedule to Off, HA doesn’t recognise this. Looking through the logs I can see the following:

17-05-04 14:57:10 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1015, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/climate/__init__.py", line 362, in async_operation_set_service
    yield from climate.async_set_operation_mode(operation_mode)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/climate/hive.py", line 99, in set_operation_mode
    self.HiveObjects.Set_Heating_Mode(operation_mode)
  File "/home/homeassistant/.homeassistant/custom_components/hive.py", line 782, in Set_Heating_Mode
    SetModeResult = Private_Hive_API_Set_Heating_Mode(NewOperationMode)
  File "/home/homeassistant/.homeassistant/custom_components/hive.py", line 609, in Private_Hive_API_Set_Heating_Mode
    API_Response_SetMode_Parsed = json.loads(API_Response_SetMode.text)["nodes"]
KeyError: 'nodes'

OK so I rebooted my Pi and Hive started working again. Not sure what happened there.

Hi @khole. I exposed my Hive boolean value to Homebridge and use that to switch the heating on and off.

My boolean is:

hive_schedule:
  name: Hive Schedule
  initial: on
  icon: mdi:temperature-celsius

I have this automation:

alias: Thermostat Off
trigger:
  - platform: state
    entity_id: input_boolean.hive_schedule
    from: 'on'
    to: 'off'
action:
  service: script.climate_hive_off

which calls this script

sequence:
  service: climate.set_operation_mode
  entity_id: climate.hive_heating
  data:
    operation_mode: "OFF"

Simply reverse that to turn it on again. HTH

I wonder if Hive were having some technical issues there end this afternoon?
I just looked at my logs and have the following:

17-05-04 13:13:34 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.hive_current_temperature is taking over 10 seconds.
17-05-04 13:13:55 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
17-05-04 13:14:25 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
17-05-04 13:23:53 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.hive_current_temperature is taking over 10 seconds.
17-05-04 13:24:14 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
17-05-04 13:32:09 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.hive_current_temperature is taking over 10 seconds.
17-05-04 13:32:30 WARNING (MainThread) [homeassistant.components.sensor] Updating hive sensor took longer than the scheduled update interval 0:00:30
17-05-04 13:35:13 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.hive_heating is taking over 10 seconds.
17-05-04 13:40:18 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.hive_heating is taking over 10 seconds.
17-05-04 13:45:23 WARNING (MainThread) [homeassistant.helpers.entity] Update of climate.hive_heating is taking over 10 seconds.
17-05-04 13:48:09 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.hive_current_temperature is taking over 10 seconds. 

In your case @gr4z it looks like it successfully got some data back from Hive but it did not contain any information about the different nodes / devices. I can add something to put a more friendly message in the log.

I have update the climate component file to change the state information to be as discussed, so this should behave more as expected with the state being on / off / schedule.

hive_climate.yaml (4.5 KB)
As before copy and replace the existing hive.py file in your climate folder

regarding location automation, I don’t have Apples, so I could use the router presence instead for when someone gets home it turns on and when everyone leaves it turns off

That’s what I use. My router and/or AP for home presence detection. Further afield that’s when I use homekit to turn the heating on when I am driving via Siri.

Can you confirm what you have changed in the latest hive_climate.py file?

I removed the def state sections from both heating and hotwater, this now reverts the state information to the default climate device state handling. seemed a good idea at the time to put current temperature, but that was before I added the specific current temperature sensor.

Excellent, updated and now reporting SCHEDULE at present rather than temp! Thanks :slight_smile:

1 Like

Did you get anywhere with the hotwater component? I updated my Hive off script to:

sequence:
  - alias: Hive Heating Off
    service: climate.set_operation_mode
    entity_id: climate.hive_heating
    data:
      operation_mode: "OFF"
  - alias: Hive Water Off
    service: climate.set_operation_mode
    entity_id: climate.hive_hotwater
    data:
      operation_mode: "OFF"

The heating goes OFF but the hotwater doesn’t do anything. Any ideas?

Yes, hotwater should be fully functional, does it turn off / on / schedule when you make the change if you click on the hive hotwater in the console?

Yeah that’s works. Must be my script. Not sure what though.

good to hear that bit works at least. I really need to get some of this automated myself…

the climate heating and climate water should work the same, with Heating being “SCHEDULE”, “MANUAL”, “OFF” and Hotwater being “SCHEDULE”, “ON”, “OFF”