custom-cards / slider-button-card

A button card with integrated slider
MIT License
105 stars 16 forks source link

Add support for sensor domain and binary_sensor domain #9

Open lizsugar opened 2 years ago

lizsugar commented 2 years ago

This adds sensor and binary_sensor controllers. These are read-only entities, so by default the slider is disabled.

Sensor domain requested in #111 Binary_sensor domain requested in #128

Screenshot: image

Notes:

Currently, tapping the card tries to trigger a non-existent toggle or turn_off/turn_on service. Neither of these domains have such services.
This is actually resolved by a separate feature I am working on to add configurable tap actions to cards regardless of slider being enabled or disabled (https://github.com/lizsugar/slider-button-card/tree/slider_tap_action), but that is not ready yet and it is larger than just these sensors cards. Once that is ready and merged, then these cards can be configured to have a tap_action of none, or more-info, or call-service, or whatever the user desires.

Sensors do not have built in min or max values, so they cannot be programmatically generated for the card per entity. The user has to add manual min: and max: values to the slider: section of the card's YAML (no GUI config for min or max exist at this time). For example:

type: custom:slider-button-card
name: Local AQI
entity: sensor.purple_air_aqi
slider:
  max: 70

The max is set to 70 because that's the AQI at which I start to have breathing problems.

or

type: custom:slider-button-card
name: Pixel 6 Battery Level
entity: sensor.pixel_6_battery_level
slider:
  max: 100

a max of 100 for batteries.

rohankapoorcom commented 2 years ago

This looks great! And I think it's ready to merge. Do you want to do a README change on this branch or include that separately with a global README change?