I’m a bit puzzled by some things that Home Assistant has access to, but don’t seem to be available in automations.
My latest encounters with this are as follows:
iPhone Battery State: I have two iPhones in my HA Mobile App integration. When these devices are charging, HA will show this in the Battery State sensor in the device page. However, when I try to use Battery State of either iPhone in an automation, there is no charging state like there is for my Android devices. There is only: “Any state (ignoring attribute changes)”, “Unavailable”, and “Unknown”. Why the difference? HA can clearly see when it is charging, and I need this information for one of my automations.
Sonos Volume Control: I have Sonos speakers with the Sonos integration. In the device page for the speakers, I can adjust the volume under Controls. However, I don’t seem to be able to adjust/set the volume in an automation. I would like to be able to adjust the volume to make sure a TTS message isn’t too loud or too quiet. HA is clearly capable of doing this, so I don’t understand why it’s not available in automation as far as I can tell.
I have encountered other issues, but these are the ones I can remember. Are these just isolated bugs? Any advice on these types of issues?
Can you post the code you’re using to access these values, using the “preformatted text” option. Without that, it’s hard to figure out what the problem on your end might be.
I see this same behavior. In the Automation compose, after selection the “battery state” sensor for trigger, the “from” dropdown is populated with all possible values for Android devices, while iPhone devices show only any/unavailable/unknown. Checking over at the “States” browser in Developer Tools, my Android battery state sensor has an “options” attribute itemizing the four possible states, while my iPhone battery state sensor is missing that attribute. While this almost certainly explains the behavior in the Automation composer, it certainly doesn’t make sense for them to be different and is a possible bug.
That said, you are not limited by the pre-filled state options — you can still type whatever you want into the from/to fields, it’s just slightly less convenient. BUT know that the trigger is case-sensitive, so even though the state displays “Charging” in the UI, it should be “charging” (lower-case) in the automation. Sigh.
I don’t have a Sonos, but generally speaking if there is a “media_player” entity with volume support, then you can add an automation action for media_player.volume_set or volume_down. When you click “Add Action” choose “Media Player” and look for volume controls.
You’re using the UI to create an automation, and when you select your iPhone’s “battery_state” entity as the trigger, you’re only seeing “Unavailable” and “Unknown.” As opposed to “charging,” “full,” etc.
I think this must be a UI bug, although I don’t use the UI much so I am not 100% sure.
For the Sonos issue, use the “Media Player” when you’re in the “Add Action” prompt–not “Device.” Then find the media player that corresponds to your Sonos. There is a “Set Volume” option once you do that.
I think it’s a UI bug for the iPhone. You should submit a bug report for this. It seems like the kind of thing that will get fixed pretty quickly once the devs are aware.
Thank you for the tip. I’ve just confirmed that I can get the charging state info by manually typing in “Charging”, but not “charging”, which is interesting because the correct syntax is “charging” for Android.
@peterxian@d921 You are correct. The volume option is under media player, which I did not expect.
I must be missing something about how these items are organized. The speaker is a device, and the volume of the speaker is a property of that device, so I would expect to see its control under said device.