artem-sedykh / mini-humidifier

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

Target humidity with input_number #103

Closed RomchikL closed 1 year ago

RomchikL commented 1 year ago

deerma.humidifier.mjjsq has an issue: In "Humidity=Auto" mode the target_humidity attribute works fine, but in all other modes (Low, Medium, High) the target_humidity attribute equals 0 (automatically). So, I changed it with input_number and some automations (see for details)

    input_number:
        lr_humidifier_target_humidity:
          name: Favorite Level
          initial: 50
          min: 30
          max: 60
          step: 1

        - type: custom:mini-humidifier
          entity: fan.lr_humidifier
          name: Hum
          model: 'xiaomi_miio_airpurifier:deerma.humidifier.mjjsq'
          target_humidity:
            state:
              entity: input_number.lr_humidifier_target_humidity

But now I cannot change the value of the input_number via the mini-humidifier card. I try to change (e.g. from 50 to 40), but it becomes back 50 and nothing changes.

regevbr commented 1 year ago

if you override the target humidity, you need to provide its full configuration if you want to act on changes, see https://github.com/artem-sedykh/mini-humidifier#target-humidity The original preset configuration is

https://github.com/artem-sedykh/mini-humidifier/blob/1e53664907b07bd8b652b98d86fb1e4bdc83db7b/src/configurations/xiaomi_miio_airpurifier/deerma_humidifier_mjjsq.js#L14-L27

RomchikL commented 1 year ago

@regevbr , Yep, I tried to write the "change_action" block, but had no success. Now, it seems, it works with the following config:

        - type: custom:mini-humidifier
          entity: fan.lr_humidifier
          name: Hum
          model: 'xiaomi_miio_airpurifier:deerma.humidifier.mjjsq'
          target_humidity:
            state:
              entity: input_number.lr_humidifier_target_humidity
            change_action: |
                (selected, state, entity) => {
                  const options = { entity_id: entity.entity_id, value: selected };
                  return this.call_service('input_number', 'set_value', options);
                }