artem-sedykh / mini-humidifier

Minimalistic humidifier card for Home Assistant Lovelace UI
MIT License
155 stars 26 forks source link

Slider returns to the default value when target humidity is set #111

Closed agav85 closed 1 year ago

agav85 commented 1 year ago

I have a problem with slider - it is not showing set target humidity but returns back to minimum (default) value after sliding to the target value. Though the target humidity is set well. Slider just does not show the set value.

regevbr commented 1 year ago

Please share full card configuration, otherwise I can't help

agav85 commented 1 year ago

Thanks for prompt response!

    - type: custom:mini-humidifier
      entity: humidifier.deerma_jsq2w_415f_humidifier
      model: 'deerma.humidifier.jsq2w' 
      power:
        type: toggle
      indicators:
        humidity:
          icon: mdi:water
          unit: '%'
          source:
            entity: sensor.home_humidity
        temperature:
          icon: mdi:thermometer
          unit: '°C'
          source:
            entity: sensor.home_temperature
        tankfilled:
          source:
            entity: binary_sensor.deerma_jsq5_415f_the_tank_filed
        tankempty:
          source:
            entity: binary_sensor.deerma_jsq5_415f_water_shortage_fault
        alarm:
          source:
            entity: switch.deerma_jsq2w_415f_alarm

      target_humidity:
        icon: 'mdi:water'
        state:
          attribute: target_humidity
        unit: '%'
        hide: false
        disabled: false
        min: 40
        max: 70
        step: 1
regevbr commented 1 year ago

Can you please share your entity attributes as well? Something like: image

I suspect that the current value is outside of the range you set up of [40,70]

Also you did not set the change_action attribute which is a must, otherwise any changes to the sliders do nothing

agav85 commented 1 year ago

I have corrected the range setup as per spec:

Developer Tools – Home Assistant 2023-02-08 20-31-19

And added change_action attribute:

    - type: custom:mini-humidifier
      entity: humidifier.deerma_jsq2w_415f_humidifier
      model: 'deerma.humidifier.jsq2w' 
      power:
        type: toggle
      indicators:
        humidity:
          icon: mdi:water
          unit: '%'
          source:
            entity: sensor.home_humidity
        temperature:
          icon: mdi:thermometer
          unit: '°C'
          source:
            entity: sensor.home_temperature
        tankfilled:
          source:
            entity: binary_sensor.deerma_jsq5_415f_the_tank_filed
        tankempty:
          source:
            entity: binary_sensor.deerma_jsq5_415f_water_shortage_fault
        alarm:
          source:
            entity: switch.deerma_jsq2w_415f_alarm

      target_humidity:
        icon: 'mdi:water'
        state:
          attribute: target_humidity
        unit: '%'
        hide: false
        disabled: false
        min: 40
        max: 80
        step: 1
        change_action: >
          (selected, state, entity) => {
          const options = { entity_id: entity.entity_id, humidity: selected };
          return this.call_service('humidifier', 'set_humidity', options);
          }

But the behavior is still the same :(

agav85 commented 1 year ago

And the value I set with the slider is in the specified range. As I mentioned earlier, nevertheless the slider goes to 0 (minimum) value after setting it, this target value is written. It can be confirmed through Mihome app. It changes there. But the slider doesn't show the current value.

One more thing - the default card, suggested by HA through the Add to dashboard menu, works fine. But I like custom card better!

regevbr commented 1 year ago

you don't have an attribute in the entity called target_humidtiy you need to change in your config to humidity....

agav85 commented 1 year ago

Thank you for your time! It worked this way. Sorry for that. Here is the final config:

    - type: custom:mini-humidifier
      entity: humidifier.deerma_jsq2w_415f_humidifier
      model: 'deerma.humidifier.jsq2w' 
      power:
        type: toggle
      indicators:
        humidity:
          icon: mdi:water
          unit: '%'
          source:
            entity: sensor.home_humidity
        temperature:
          icon: mdi:thermometer
          unit: '°C'
          source:
            entity: sensor.home_temperature

      target_humidity:
        icon: 'mdi:water'
        state:
          attribute: humidity
        unit: '%'
        hide: false
        disabled: false
        min: 40
        max: 80
        step: 1
        change_action: >
          (selected, state, entity) => {
          const options = { entity_id: entity.entity_id, humidity: selected };
          return this.call_service('humidifier', 'set_humidity', options);
          }