bushvin / hass-integrations

My custom Home Assistant integrations
Apache License 2.0
62 stars 11 forks source link

Issues with true/false values within attributes #61

Closed Switch123456789 closed 9 months ago

Switch123456789 commented 10 months ago

Some attributes return on/off and some return true/false. image The true/false values cause issues when I use conditions in scripts, because these states aren't recognized by HA if i put them in quotation-marks. I can work around that by removing them manually but this disables the ui-editor. image I guess HA doesn't like booleans in attribute-values and persists on having strings (on/off).

bushvin commented 10 months ago

This has actually nothing to do with the integration, rather the way the state condition is implemented. When you look at this article, you can see there is a condition for numeric state, and "regular" state, no boolean state. The actual code itself is clear on the matter. It accepts strings or lists of strings. So, I am afraid you will need to either use a template condition or use 'on' for true or 'off' for false

This is a possible solution

condition: template
value_template: >-
  {{ not state_attr("media_player.ha_media_player","consume_mode") }}
Switch123456789 commented 9 months ago

Hey thank you for clarifying! Sorry for the delay, I was pretty busy recently.

That's the thing, 'on' & 'off' doesn't work with conditions but true & false does for whatever reason (even if not officially supported). So my scripts works fine with the action I screenshoted. From my example, only repeat works properly because it returns on or off, instead of true or false.