junkfix / numberbox-card

Replace input_number sliders with plus and minus buttons
110 stars 9 forks source link

[FEATURE REQUEST] Support for thermostats / other types of devices #24

Closed dodekaphilist closed 3 years ago

dodekaphilist commented 3 years ago

As this card is inspired by the simple thermostat card, might it be possible to actually support thermostat entities natively?

image

Proposal:

  - entity: climate.thermostat
    type: 'custom:numberbox-card'
    icon: 'mdi:thermostat'
    unit: °C

Besides native support for specific entity types, I suppose a generalized approach would allow you to define an attribute for a certain an entity to controll, and to provide a service if necessary to support even more devices (like fans, cover, etc).

Generalized example:

  - entity: fan.kitchen
    attribute: percentage
    service: fan.set_percentage
    type: 'custom:numberbox-card'
    icon: 'mdi:thermostat'
    unit: °C
htmltiger commented 3 years ago

Just added support, please try it.

dodekaphilist commented 3 years ago

The implementation needs a little tweek to work: We need to remove the check for service type in line 223.

Apart from that, I think we need to add some other checks to remove error messages during operation due to bad configuration. I propose that once a non-number entity is detected, values for state and service are required. I see why one could need different values for state and parameter but maybe we could write it that why that it takes the state as the parameter by default to reduce clutter? Also, it's somewhat unusual to name services without their namespace in Home Assistant. I expect people to find use cases where the entity type and the service namespace aren't the same, so we might wanna make a full declaration?

Also, I found that changing a step doesn't work when no limits are defined. We need to either show an error message during configuration or rather remove this limitation (I think it's not necessary for all cases).

One last thing is probably an issue a lot of physical devices are facing. When setting a new value, it takes some time to get into effect on the device. In my case I saw, that after the shown value switches from the new value in red back to the original value in black, before this value updates to the actual value. HA does fix this by waiting for the value to get updated before changing the font color to normal.