core: Hive integration not working
The problem
Any operations to set heating or hot water values result in a error being thrown.
This was working yesterday on version 2025.2.2, upgraded to 2025.2.3 to see if that resolved but same issue. Also tried removing integration and adding again but this does not resolve issue.
Seems like Hive API is rejecting request but I can’t see enough details in the logs to investigate further.
What version of Home Assistant Core has the issue?
2025.2.3
What was the last working version of Home Assistant Core?
2025.2.2
What type of installation are you running?
Home Assistant OS
Integration causing the issue
hive
Link to integration documentation on our website
https://www.home-assistant.io/integrations/hive/
Diagnostics information
2025-02-14 12:41:41.353 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140623382675664] Unexpected exception Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 245, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …<7 lines>… ) ^ File “/usr/src/homeassistant/homeassistant/core.py”, line 2794, in async_call response_data = await coro ^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/core.py”, line 2837, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 1007, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ hass, entity, func, data, call.context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 1079, in _handle_entity_call result = await task ^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/components/hive/init.py”, line 94, in wrapper await func(self, *args, **kwargs) File “/usr/src/homeassistant/homeassistant/components/hive/switch.py”, line 76, in async_turn_off await self.hive.switch.turnOff(self.device) File “/usr/local/lib/python3.13/site-packages/apyhiveapi/plug.py”, line 215, in turnOff return await self.session.heating.setHeatOnDemand(device, “DISABLED”) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.13/site-packages/apyhiveapi/heating.py”, line 403, in setHeatOnDemand resp = await self.session.api.setState( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ data[“type”], device[“hiveID”], autoBoost=state ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File “/usr/local/lib/python3.13/site-packages/apyhiveapi/api/hive_async_api.py”, line 288, in setState resp = await self.request(“post”, url, data=jsc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.13/site-packages/apyhiveapi/api/hive_async_api.py”, line 92, in request raise HiveApiError apyhiveapi.helper.hive_exceptions.HiveApiError 2025-02-14 12:41:42.283 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140623382675664] Unexpected exception Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 245, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ …<7 lines>… ) ^ File “/usr/src/homeassistant/homeassistant/core.py”, line 2794, in async_call response_data = await coro ^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/core.py”, line 2837, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 1007, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ hass, entity, func, data, call.context ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 1079, in _handle_entity_call result = await task ^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/components/hive/init.py”, line 94, in wrapper await func(self, *args, **kwargs) File “/usr/src/homeassistant/homeassistant/components/hive/switch.py”, line 71, in async_turn_on await self.hive.switch.turnOn(self.device) File “/usr/local/lib/python3.13/site-packages/apyhiveapi/plug.py”, line 201, in turnOn return await self.session.heating.setHeatOnDemand(device, “ENABLED”) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.13/site-packages/apyhiveapi/heating.py”, line 403, in setHeatOnDemand resp = await self.session.api.setState( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ data[“type”], device[“hiveID”], autoBoost=state ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File “/usr/local/lib/python3.13/site-packages/apyhiveapi/api/hive_async_api.py”, line 288, in setState resp = await self.request(“post”, url, data=jsc) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.13/site-packages/apyhiveapi/api/hive_async_api.py”, line 92, in request raise HiveApiError apyhiveapi.helper.hive_exceptions.HiveApiError
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 20
- Comments: 179 (4 by maintainers)
Just to add to all the other people’s help (amazing thanks!) here is what I have written in my own documentation if it helps anyone. I am also not an expert so wanted to write it down!
Code - add the following where I have added [Insert Code]
“User-Agent”: “Hive/12.03.1 iOS/18.3.1 Apple”,
So you end up with:
I was stuck exactly the same as you not being able to get access to the right .py file on my HAOS install. After a lot of digging I found a way that worked:
Then in the add-on terminal:
docker exec -it homeassistant /bin/bashcd /usr/local/lib/python3.13/site-packages/apyhiveapi/api/vi hive_async_api.pyhttps://github.com/Pyhass/Pyhiveapi/pull/86 was just merged 🤞
Same issue here also. Seems to have started today about 11:30AM (GMT) (in the UK). Automations running fine earlier, then suddenly this started. Can receive data from Hive servers fine - temps and current status etc. But any attempt to send a command (Climate.set_temperature) or set HVAC etc. fails.
It seems perhaps a server side change in Hive’s servers?? Looking at the logs I’m seeing 403 errors with their API:
2025-02-14 13:56:51.162 | ERROR | apyhiveapi.api.hive_async_api:request:87 - Something has gone wrong calling https://beekeeper.hivehome.com/1.0/nodes/heating/XXXXXXXXXXXXXXXX - HTTP status is - 403(I replaced the original string with “X” when posting here)Things I have tried:
It does not seem to be a local issue, it very much appears to be a Hive server side change that has suddenly been enacted. Can Ping their API but any attempt to send calls / POST - Error 403 Forbidden. Could this possibly be Hive silently locking down their API to everything except their own App? As sadly more IoT manufacturers seem to be doing these days. (The Hive app itself works fine). Possibly the final push to make me ditch the Hive Hub and just add my Hive setup directly to ZHA locally and no longer rely on Hive servers.
I hope we find a solution.
I’ve raised PR on pyhiveapi to fix this https://github.com/Pyhass/Pyhiveapi/pull/86 Not sure how active the maintainers are though or the turn around to get this released.
Hi all, I think I have tracked down the issue. It looks like Hive have done something pretty rudimentary by just checking for a user-agent being sent in the request. Just need someone to verify that knows how to access the HA core files. I am not sure how we get this into the next build of HA if it does work but I’m sure someone cleverer than me can work that out as any HA updates will overwrite this.
The file is in the directory /usr/local/lib/python3.13/site-packages/apyhiveapi/api Edit hive_async_api.py and add the User-Agent line below which I took from the iOS app Restart HA
async def request( self, method: str, url: str, camera: bool = False, **kwargs ) -> ClientResponse: “”“Make a request.”“” data = kwargs.get(“data”, None)
I went to HACS intergration and search Hive Custom Component like mentioned above and i am delighted this has fixed the issue without having to apply any manual update and after thinking about removing hive it is now back WORKING!
And for those not used to/never used VI to edit files:
After running
vi hive_async_api.py"authorization": self.session.tokens.tokenData["token"],"User-Agent": "Hive/12.03.1 iOS/18.3.1 Apple",edit: Forgot the :
This is for project management software.
Thank you for putting together an idiot’s guide. Worked for me on HA Green box.
We, who consume open source. community supported software and systems sometimes become blasé to the effort that is put in on a day to day basis. When things go wrong (and waking up to a freezing house is the definition of “going wrong” to me!) it brings it home how important this effort is. Many thanks to all from me!!
Hi All, I want to thank @BlythMeister for finding and coming up with a fix for this issue. @BlythMeister I have merged your PR into the code base and created a new version of the backend which has now been published. On the back of that, I have also raised a PR with the Home Assistant team to upgrade the dependency the Hive integration uses. Once that is merged, we will just need to wait for the next minor Home Assistant release.
You can follow the Home Assistant PR here - https://github.com/home-assistant/core/pull/138569
One again @BlythMeister thanks for your support on this.
You have to ssh into the host which means use need to do this https://developers.home-assistant.io/docs/operating-system/debugging/#ssh-access-to-the-host
Then once you ssh to port 22222 you then need to get into a bash shell inside the container so run this docker exec -it homeassistant /bin/bash
That is presuming you are running HA in docker of course which I do but since HA can be run in many different ways that’s as far as my knowledge goes as I run it on a PI.
Be very careful if you aren’t sure what you are doing as you could brick it quite easily with root access into the host and accessing the container at that high a level.
The fix for the main Hive integration (not the HACS installed addon) won’t be available until HA 2025.2.5 - .4 was released before this issue happened.
Install the Advanced SSH & Web Terminal from the addons page - make sure you run it with protection mode switched off so you can access the .py file - and then follow the instructions detailed in the comment at https://github.com/home-assistant/core/issues/138524#issuecomment-2666693220
I’m not sure quite who was first to work out what the fix was, but thanks to everyone who chipped in with the intstructions on how to fix it 😃
Essentially, unless you need the extra sensors…revert back to official channel next weekend after release then 🤣
The payload send by the hive app was compares to what HA sends and this showed the missing information.
At 1st it was believed they were checking it was their app, but turns out it wasn’t a “kill 3rd party” move, just a move to check there was a user agent. Tbh, it could of easily been a WAF (web application firewall) update. I know the default in Azure and Cloudflare these days validates the user-agent on WAF.
Several HA integrations have 2 versions.
@BlythMeister As was mentioned by others above, official integrations are tested and added as part of the HA core, they can often be slower to update as they go through a rigorous checking process and work more seamlessly with HA. In HACS an integration is not “official” as it is not part of the core of HA, it is often just maintained by a single person as a personal project etc. HACS integrations are great, and they can be updated more quickly as they don’t have the rigorous testing and implementation through the “official” channels like the Core integrations. However sometimes HACS integrations can become stale, be slightly more unstable, not updated any more, if the person moves onto other projects etc. and potentially a little more prone to bugs as there are theoretically less tests and checks by the official team.
In this situation with Hive. A fix has been found, it was submitted to the “official” team for review and has now been checked and accepted, soon it will be sent out to everyone as an update to HA. In the meantime, the same fix was applied to the HACS version of Hive - Because the HACS version is “unofficial” the person whom updated it, simply sent it straight out to everyone as an Update in HACS and they didn’t need to have it checked over by the “official” core team or wait for the next HA update to come around and make the fix part of it.
Hence as of right now - The “official” Hive integration is not working - A fix has been found and accepted - We are just waiting for the next HA update to come around and then everyone will get it. (In the meantime you can manually fix the official integration if you follow the steps above The HACS version is already fixed and the update has been sent out to everyone.
So just to be clear and I did say originally when I found the issue you can even send an empty string as a user-agent.
I don’t believe this is some thing that hive have implemented to stop the 3rd party addons it strikes me more as an update to one of their firewalls or configuration that they are insisting on a basic set of headers to guard against ddos attacks etc.
The change should work for anyone based upon this and should remain working until you up date HA. I made the change when I first found the issue and it worked until I upgraded from 2025.2.3 to 2025.2.4 and then made the change again and it has continued to work.
Hope that clarifies things a bit for people.
Getting this sorted so quickly is down to a collective effort. I’m fairly new to HA but not open source and this is exactly the situation where everyone helps everyone.
I have just taken the update for the Hive Custom Component (2025.1.0) that is now available in HA. This has fixed the issue without having to apply the manual update.
Thanks
@davek00997744 follow the instructions in this port and edit the file and add in the useragent line and restart home assistant. I did that this morning and it worked for me!
@KJonline , @BlythMeister and everyone else. Team effort, that seems to be what HA is all about
It wasn’t my fix it was @o2k I just made the PR.
I’ll close my bump on this repo as I think Ive missed bits lol
@BlythMeister & @o2k seem to be on it. My guess is they’re getting cold and desperate, like the rest of us
edit: added @o2k
Since the person looking after the pyhiveapi is also the maintainer of the Hive integration I think they just need to update the dependency to v1.0.2 and it should appear in the next HA release. I’m new to HA so not 100% positive but @KJonline seems very responsive as they have already merged the request and they should get a big thanks for that.
Thank you very much. I am using Hive Heating, and I can confirm that adding only “User-Agent”: “Hive/12.03.1 iOS/18.3.1 Apple” resolved the issue.
“Given that the Hive mobile app has not been updated and it continues to work, then the server side API will not have changed.”
I don’t think that’s necessarily true, and my experience with the Visonic integration last week shows me why. There, the API exposed by the Visonic/Tyco alarm API suddenly went from supporting versions 8,9,10,12 (with the Visonic integration using version 8) to just version 12, with no update of the Visonic app. However, presumably they had updated their app at some point over the last n months or years so that it used version 12, and therefore dropping the older versions didn’t need further changes. Luckily 12 is a superset of 8 so it was just a matter of telling the integration to put 12.0 rather than 8.0 in all the URLs, and the rest of the code remained unchanged.
Similarly, Hive might have released a version of the app which works with whatever has changed at any point in the past, and then after some appropriate period of grace they’ve made the matching changes to the service. If that change is breaking, well, the Hive integration is broken.
Do you reckon we could get a bulk discount on some Nest thermostats?
In the meantime, one can locally take control of Hive directly with ZHA / Z2M and totally do away with Hive servers and the Hive hub.
Working instructions on how to it here.
TBH, Hive is one of the final integrations on my HA that is still cloud dependant. Considering how Centrica manage their servers and app I’ve been inclined to just locally pair my hive system to my ZHA and no longer worry about external servers or Corporate entities suddenly making changes / cutting off access / 3rd parties. Etc.
Just to confirm, 2025.2.5 seems to have sorted it for me too. I’ve not got the knowledge or skills to troubleshoot and find fixes like all of you, and I didn’t get a chance to try the fix that was posted. So I thought I’d take the hit on updating early instead!
I just installed 2025.2.5 rebooted and all seems ok. Thanks to all that found the fix.
thanks this helped, i thought it someway different from docker installations…
For anyone looking for a step by step guide :-
https://github.com/home-assistant/core/issues/138524#issuecomment-2660831140 is a good summary of how to fix the issue temporarily. thanks everyone for the great collaboration here.
Use the details from this port to edit the file. You can install terminal and do it locally with out having to remotely connect via windows, it is much easier.
https://github.com/home-assistant/core/issues/138524#issuecomment-2660842816
great community collaboration here, thanks to all the contributors for quick fixes.
looking for a help here, i am having HA OS hosted on Hyper-V ( via vhdx, and obviously windows host). I am clueless on how to get into these core python files in HAOS system folders (/usr/local/lib) via windows. I don’t think the ssh terminal in HA can go into system files . I tried it but it is not finding the python folder … All the samples are on the dockers … any help much appreciated.
thanks
@krisblackhall & @BlythMeister yes I do maintain both. The reason the HACs version doesn’t really get out of date and is easy to maintain is because bar the sensors.py file all the other elements of the hacs version import the core version into it. Basically where no customisation is required it re-uses the core integration.
The reason why the hacs version exists is the extra sensors, a while back there where sensors in the HA system that didn’t have support by architectural design. So we created the hacs version to allow people to access this data.
The architectural design of HA has changed a lot over the years and I believe these sensors are support now. It’s just a case of the doing the work to move them in the core of HA.
I always prioritise the core implementation of the hive integration.
I don’t think this is a different version as you still need Hive intergration. Its more to add on that works with the fix as above. it does look like the intergration will get an update but this is just a quicker wat to update
Thank you to everyone for coming together and discovering the issue and finding a fix. That’s what HA is all about. I have implemented the fix by editing the file and all resolved well. Awesome the Custom HACS Component is already updated for those that use that!
@o2k Many thanks for making the discovery and defining the User Agent line being the puzzle piece we needed. @BlythMeister thanks for being so helpful and pushing for the resolution. @craigusus & @akajake thanks for the clear step-by-step guide for using vi and editing the file. And of course thanks to @KJonline for putting in the PR so quickly, and to all others for contributing.
I see that Joostlek has just recently approved the merge and it will be in the next patch, likely on 21/02/2025.
Fantastic!! I have applied the file edit as per all the above advice and all devices are back up and working! Thanks to all you very clever people and the amazing HA community for providing such a quick fix and clear advice.
Thanks so much to SRJohnston and all others for the super clear instructions for getting this working again - very helpful and generous.
Honestly, I’m relatively uninformed on this stuff but not afraid to play. Having read everything here and following all the instructions I got it working. Honestly, it’s quite easy. Go for it (but maybe back up first)
On Sat, 15 Feb 2025, 10:28 davek00997744, @.***> wrote:
you guys are actually my heroes. its all working. thank you all so much for your patience with me!!!
Odd, mine was fine with it in. Are you already using port 22 on the HA server (maybe for the other terminal add-on)?
I turned off SSH entirely by deleting the port number in the ‘Network’ section. If someone’s only using the add-on through the WebUI that’s probably simplest - avoids port conflicts and doesn’t open an unnecessary port into your server.
Just paste the following into the config tab of the Advanced SSH before starting it / restart it once you have added. Just make sure you stop/uninstall the add on or add better security when you are done!
I’m sure someone will tell me some of the below isnt necessary but this is what happened to be in my config from a couple of years ago and caused me no issues today with this fix!
Thank you very much mate. I have my heating back again!!!
@spasypaddy I would anticipate it being in 2025.2.5, which will on current schedules be within a week or so. I’d appreciate being corrected by the more knowledgeable, but as I understand it the downside of an integration being shipped with the core is that providing a fixed version other than via a core update is difficult, usually involving installing it a custom component manually or via HACS. And that in turn has its own issues, notably (as people upthread are saying) getting back onto the mainstream release.
Depending on how you’re running HA, applying the fix by hand is pretty straightforward. Install the Advanced Terminal, set the Protected Mode option off, and open the web interface. “docker exec -it homeassistant /bin/bash” to get into the right container, “cd /usr/local/lib/python3.13/site-packages/apyhiveapi/api” to get to the right directory, “vi hive_async_api.py” to edit the file in question. If you’re not familiar with vi I’m sure I/we/someone can talk you through the process, or we could provide a snippet of sed to do it with one command. You want to end up with this at around line 66: the key point is adding the User-Agent line (and the trailing comma is, to the horror of people used to other languages, considered good style in Python).
@darkmatter24 if we’re ever in the same country I owe you a beer for that!
Thank you all… until next time Hive throw another curve ball
A new version with the changes has been released https://github.com/Pyhass/Pyhiveapi/releases/tag/v1.0.2
We just need to see it rolled out in the next HA update now, I suppose.
Same thing for me. The last time I can confirm it worked was 08:00 GMT.
Changing the User-Agent works, but I couldn’t find a way to edit the file in the container. I’ll post these commands here that copy the file to the host and back again, so the file can be edited on the host or accessed via samba etc.
Another thanks for @o2k All good on my end.
No as you have made the change inside the container, obviously upgrading HA Core will revert it though until the PR if pulled that @BlythMeister has submitted.
Thanks @o2k can confirm that fixed my installation (2025.1.4 running in Docker).
To confirm, the fix works for me (just adding “user-agent”).
Hi Webchuzz,
I setup a proxy on my mac and sent the traffic from the iPhone through it so I could see it.
I can confirm that populating the User-Agent HTTP header with the value above fixes the issue. I can now successfully set the target temperature from HA.
I can confirm that adding the user agent fixes the issue, regardless of the capital A or not in authorization.
Restarted HA and everything works again. May I ask how did you manage to capture the user agent from the iOS app?
I can’t get it working with just the capital “A” although it should be capitalised, I still need a User-Agent even if it just says Hive or even an empty string
+1 for this. All working until midday gmt. Rolled back to previous version but no joy. Can see all the sensors but not control them - Example from a hive light: “Failed to perform the action light/turn_off. unknown error”
Think I found the Facebook page. I posted an issue on it, hopefully they will respond:
https://www.facebook.com/Hive/?locale=en_GB
Also created a post here on Hive to try and get some assistance:
https://community.hivehome.com/s/question/0D5Tb00000T58CUKAZ/hive-heating-home-assistant
Oh gosh, me also, all entities failing…really hope this gets resolved!..I have about 20 bulbs/plugs and a bunch of rad stats…fingers crossed as I simply don’t have time these days to implement any work-around. Usually a pretty solid reliable integration.
Same for me it set my heating at lunchtime today 14/02/2025 but did not set it at 3:34pm. I updated home assistant to latest version this afternoon. I then reverted to the previous backup that was working this morning, still no joy.
I am going to be well annoyed if this is an intentional stop from hive, I would be even more annoyed if I have to move back to nest because if this
True, this seems to have all the hallmarks of an intentional, server side blocking of 3rd party access.