Skip to content
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

Support binary sensors #89

Open
TTLucian opened this issue Nov 7, 2021 · 3 comments
Open

Support binary sensors #89

TTLucian opened this issue Nov 7, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@TTLucian
Copy link

TTLucian commented Nov 7, 2021

Certain attributes show as unavailable on the card. The sensors are enabled and working.
mop_attached
water_box_attached
I think this happens because they are binary_sensors and currently the card only reads "sensor" values, but not "binary_sensor" values.

@dizzad
Copy link

dizzad commented Nov 7, 2021

Same for me
Update to 4.4.0 right now
image

@benct
Copy link
Owner

benct commented Nov 7, 2021

Have look at #84, things changed in 2021.11.0. The binary sensors are not supported as of now, I'll see if I can do something about that soon.

If the card still does not work, try this.

@TTLucian
Copy link
Author

TTLucian commented Nov 7, 2021

Thanks. I've seen #84. Card works for ok "sensor" state but not for "binary_sensor" state (like mop_attached and water_box_attached).
As a workaround, template sensors can be manually created with binary_sensor state, like so:

template:
  - sensor:
      name: Robot Mop Attached
      unique_id: sensor.robot_mop_attached
      state: >
        {% if is_state('binary_sensor.robot_mop_attached', 'off') %}
        No
        {% elif is_state('binary_sensor.robot_mop_attached', 'on') %}
        Yes
        {% endif %}
      availability: >
        {% if is_state('vacuum.robot', 'unavailable') %}
          false
        {% else %}
          true
        {% endif %}
      icon: >
        {% if is_state('binary_sensor.robot_water_box_attached', 'on') %}
          mdi:square
        {% else %}
          mdi:square-off
        {% endif %}

  - sensor:
      name: Robot Water Box Attached
      unique_id: sensor.robot_water_box_attached
      state: >
        {% if is_state('binary_sensor.robot_water_box_attached', 'off') %}
        No
        {% elif is_state('binary_sensor.robot_water_box_attached', 'on') %}
        Yes
        {% endif %}
      availability: >
        {% if is_state('vacuum.robot', 'unavailable') %}
          false
        {% else %}
          true
        {% endif %}
      icon: >
        {% if is_state('binary_sensor.robot_water_box_attached', 'on') %}
          mdi:water
        {% else %}
          mdi:water-off
        {% endif %}
  - type: custom:xiaomi-vacuum-card
    entity: vacuum.robot
    name: Robot
    vendor: xiaomi
    image: /local/community/lovelace-xiaomi-vacuum-card/vacuum.png
    attributes:
      main_brush:
        key: main_brush_left
      side_brush:
        key: side_brush_left
      filter:
        key: filter_left
      sensor:
        key: sensor_dirty_left
      mop_attached:
        label: 'Mop attached: '
        key: mop_attached
      water_box_attached:
        label: 'Water box attached: '
        key: water_box_attached

Result:
Untitled

@benct benct changed the title Certain attributes show as unavailable since HA update 2021.11 Support binary sensors Mar 4, 2022
@benct benct added the enhancement New feature or request label Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants