New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homepod Mini: Temperature and Humidity sensors not available as entity #103295
Comments
Hey there @postlund, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) apple_tv documentation |
These are only available via HomeKit and will thus not be exposed via the Apple TV Integration as pyatv does not support HomeKit (and I don't plan to support it either). |
To be able to add these to HomeKit, they would need to be unpaired first. Conceptually, this just does not make sense so I don't think that there would be any way for us to do that. |
To integrate HomePod Mini sensors into Home Assistant when direct integration isn't possible, you can use the following method:
This method allows you to bypass the limitations of direct integration of HomePod Mini sensors into Home Assistant by using HomeKit as an intermediary. |
Thanks @FermedePommerieux, this method works quite well! However, the humidity value only gets correctly populated when I manually test the automation from the HomeKit app, otherwise it registers as 0.0%. edit: I got it working, for some reason the Home automation was using the "Current state" variable instead of "current relative humidity". Weird that it worked when manually triggering... |
Ensure your HomeKit automation is correctly set to use the 'current relative humidity' attribute from your HomePod Mini's humidity sensor. Also, verify that the automation triggers as expected. I've successfully implemented this method with three HomePod Minis, so these checks should help resolve the issue. |
Hello! Thanks for the awesome tips, following the instructions in ran into a little issue that I'm surprised you didn't (or maybe I missed something?) I could see the webhook incoming from Homekit in HASS but it is sending the data in the following format:
I can see in the logbook:
This is because the Fixed it by changing the automation line from: and now it works like a charm. Also, Homekit only worked for me using a hostname (e.g. |
🙈 Ok I'm an idiot, none of the above is necessary if you set the field in Homekit automation to Number instead of text, which wasn't clear to me. |
@FermedePommerieux, What great instructions and help. I haven't actually started yet, but I have already been able to follow all the steps. Tell me, I have 3 Homepods minis, do you have a template that I could use or would you create all 3 Homepods separately using the template? I'm asking because you mentioned that you have activated it for 3 Homepods and have certainly already played through all the pros and cons, whether it makes sense to pack everything into one automation (HA and IOs). Best regards |
If you add:
or
to the JSON requests you can also track statistics on them instead of just history |
Please tell me where exactly I need to insert this? in homekit automation or somewhere in the sensor in home assistant? |
I found a more correct way to add a history for the sensor. Instead of the legacy sensor template, you need to use the new sensor template format https://www.home-assistant.io/integrations/template, where you can specify state and device classes. Below is a piece of code from point 2, which I converted to a new format. template:
- sensor:
- name: "homepodmini_XXXXX_temperature"
unique_id: ff02eebc-b4a5-4761-906c-d4603c70266f
unit_of_measurement: '°C'
device_class: temperature
state_class: measurement
state: "{{states('input_number.homepodmini_XXXXX_temperature')}}"
- name: "homepodmini_XXXXX_humidity"
unique_id: a5e5cf60-7ac1-4147-85d6-fa5e4536c462
unit_of_measurement: '%'
device_class: humidity
state_class: measurement
state: "{{states('input_number.homepodmini_XXXXX_humidity')}}" |
@FermedePommerieux: Nice work, thank you! I don't know why, but I had some problems with the automation stored under bullet point 4. In case anyone else has these problems, here is the formatting of the automation:
|
Nice ! Would you like me to update my initial post ? |
Hello Seger, Thank you for your question regarding the setup of the automation. To clarify, you will indeed need just one automation to manage all three devices. This single automation is designed to update the sensor corresponding to the specific HomePod Mini that sends a webhook. It's important to note that any sensor you wish to update via a webhook triggered by each HomePod Mini must be manually configured in Home Assistant (HA). As of now, I have not yet figured out a way to add sensors on the fly in HA, so this setup must be done carefully for each device. In summary, you do not need to create separate automations for each HomePod Mini. One automation can manage all three, but each HomePod Mini requires specific manual configuration to ensure that the correct sensor is updated based on the received webhook. I hope this clarifies the situation. Please don't hesitate to reach out if you have more questions or need further assistance with your setup. Best regards |
However, I've noticed an issue with one of my HomePod Minis in cold environments (around 12°C): the temperature readings do not drop below 17.5°C. I suspect this might be related to the operating temperature of the HomePod Minis themselves. Therefore, be cautious when setting up automations that rely on triggering at temperatures lower than 17.5°C. |
You do it through webhooks and submitting to specific endpoints for your sensors and HA will create sensors for you on the fly, no need at all to configure anything for it. For example, for my kitchen homepod: Get contents of:
Get contents of
You will now have two new sensors in HA, namely Note that you can simply change the sensor names, so if you want to have a sensor called Hope that helps! I've got it running for 4 homepods in my house, which means you have to unfortunately call 8 different URLs to get both sensor and humidity but no config on the HA side of things. |
Super cool workaround. But the majority of Home Assistant users will probably not be able to find this and learn from this. It would be better if you guys create a new topic in the Community forum at https://community.home-assistant.io/ and discuss there? Additionally, we can continue monitoring this specific issue (no native support) with GitHub. Thanks! |
@FermedePommerieux yeah sure! |
Wow, this is a perfect example of KISS: Keep It Stupidly Simple! I absolutely love it!
Responding to the suggestion about creating a new topic on the Home Assistant community forum, I am fully supportive of it. It's indeed a great idea to disseminate this workaround to a broader audience. With your permissions, I plan to initiate a new, simplified version of the how-to guide, utilizing Mensoh's method. I'll submit it here before opening a new topic. Additionally, I would be very grateful for any English-language screenshots of HomeKit automations. These visual aids would be tremendously helpful in enhancing understanding and aiding others in implementing similar setups in our community. |
Well, it seems that the /api/states/ method requires authentication. How did you manage that? This might make configuration in HomeKit more challenging. I'm planning to explore calling localhost/api/states/ in the automation to create sensors on the fly, without needing additional configuration. I'll look into it tomorrow. |
Ah this is a fair point, you need to enable the REST API and create an API key, you can read more on how to do that here in the HA documentation. So this means in your Apple Home automation when you make the then in the |
I've found a way to bypass the limitation and eliminate the need for authentication/configuration: a simple Python script that can be called from the automation. update_homekit_sensor.py: sensor_name = data.get('sensor_name')
sensor_state = data.get('state')
sensor_attributes = data.get('attributes', {})
hass.states.set(sensor_name, sensor_state, sensor_attributes) I recognize that this approach represents a decrease in security and poses a potential risk of overloading Home Assistant with a large number of spam sensors, which could lead to problems if misused. Although I prefer using authentication with HomePod Minis, their setup can be quite tedious. Therefore, this method, albeit less elegant and somewhat 'rougher', seems to be more practical and easier to implement for less experienced users. Here is the updated automation, which doesn't require any further configuration: alias: Homekit - Sensor Collection
description: Processes temperature and humidity data from the HomePod Mini
trigger:
- platform: webhook
webhook_id: homekit_sensors
allowed_methods:
- POST
local_only: true
id: WebHook
- platform: time_pattern
minutes: /2
id: time
action:
- choose:
- conditions:
- condition: trigger
id: WebHook
sequence:
- service: python_script.update_homekit_sensor
data:
sensor_name: sensor.{{ trigger.json.sensor }}_humidity
state: "{{ trigger.json.humidity }}"
attributes:
unit_of_measurement: "%"
state_class: humidity
device_class: measurement
- service: python_script.update_homekit_sensor
data:
sensor_name: sensor.{{ trigger.json.sensor }}_temperature
state: "{{ trigger.json.temperature }}"
attributes:
unit_of_measurement: "°C"
state_class: temperature
device_class: measurement
- conditions:
- condition: trigger
id: time
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.homekit_sensors_update
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.homekit_sensors_update
mode: parallel
max: 10 I propose offering two ways of configuration: one secure using an API key and one less secure with a Python script. I'm planning to create a blueprint for this. |
Integrating HomePod Mini Sensors into Home Assistant When Direct Integration Isn't PossibleYou can use the following two methods: Method A (Less Secure):
This method uses HomeKit as an intermediary to integrate HomePod Mini sensors into Home Assistant. Method B (More Secure, No Python Script Required):
|
Here is the link to the community guide topic: https://community.home-assistant.io/t/how-to-integrate-homepod-mini-sensors-into-home-assistant-when-direct-integration-isnt-possible/665074 |
Newb Q- is it relevant the entity name has XXXX in homepodmini_XXXXX_humidity? |
The choice of the entity's name is entirely up to your personal preferences and how you want to organize and identify your devices. |
@mensoh, However, the values must be summarised as a dictionary under the key JSON format for temperature:
JSON format for humidity:
|
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. |
Not yet fixed |
The problem
HomePod mini includes a temperature and humidity sensor, which are exposed to Apple’s home app.
However, HA’s Apple TV integration does not detect these sensors to make them available as an entity.
What version of Home Assistant Core has the issue?
core-2023.11.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Apple TV
Link to integration documentation on our website
https://www.home-assistant.io/integrations/apple_tv
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: