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

Не проблема, благодарность #112

Open
alex2beard opened this issue Feb 24, 2023 · 1 comment
Open

Не проблема, благодарность #112

alex2beard opened this issue Feb 24, 2023 · 1 comment

Comments

@alex2beard
Copy link

Добрый день, хочу выразить благодарность за дополнение для Home Assistant, очень удобное и информативное, пользуюсь так же вашим mini-climate-card, за него тоже спасибо :)
Хочу выложить свой пример использования увлажнителя Xiaomi Smart Humidifier 2 (deerma.humidifier.jsq2w), подключенный в HA через интеграцию Xiaomi Miot Auto.

Карточка :

type: custom:mini-humidifier
entity: fan.deerma_jsq2w_30e8_fan_level
secondary_info:
  type: mode
name: Увлажнитель
power:
  type: button
  state:
    entity: fan.deerma_jsq2w_30e8_fan_level
  toggle_action: |
    (state, entity) => {
      const service = state === 'on' ? 'turn_off' : 'turn_on';
      const options = { entity_id: entity.entity_id };
      return this.call_service('fan', service, options);
    }
indicators:
  vlazhnost:
    icon: mdi:water-percent
    unit: '%'
    round: 1
    source:
      # Средняя влажность всех датчиков влажности квартиры 
      entity: sensor.sredniaia_vlazhnost
    tap_action:
      action: more-info
      entity: sensor.sredniaia_vlazhnost
buttons:
  mode:
    icon: mdi:fan
    order: 1
    type: dropdown
    state:
      attribute: preset_mode
    source:
      Level1: Level 1
      Level2: Level 2
      Level3: Level 3
      Level4: Auto
    active: (state, entity) => (entity.state !== 'off')
    disabled: (state, entity) => (entity.attributes.depth === 0)
    change_action: |
      (selected, state, entity) => {
        const options = { entity_id: entity.entity_id, preset_mode: selected };
        return this.call_service('fan', 'set_preset_mode', options);
      }
  led:
    icon: mdi:lightbulb-on-outline
    order: 2
    type: button
    state:
      entity: light.deerma_jsq2w_30e8_indicator_light
    toggle_action: |
      (state, entity) => {
        const service = state === 'on' ? 'turn_off' : 'turn_on';
        const options = { entity_id: entity.entity_id };
        return this.call_service('light', service, options);
      }
  buzzer:
    icon: mdi:bell-outline
    order: 3
    state:
      entity: switch.deerma_jsq2w_30e8_alarm
    toggle_action: |
      (state, entity) => {
        const service = state === 'on' ? 'turn_off' : 'turn_on';
        const options = { entity_id: entity.entity_id };
        return this.call_service('switch', service, options);
      }

image
image

Автоматизация переключения режима :

alias: Увлажнитель минимальный режим
description: >-
  Устаноака минимального режима на увлажнителе при средней влажности больше 45%
  в течении 30 минут.
trigger:
  - platform: numeric_state
    entity_id: sensor.sredniaia_vlazhnost
    for:
      hours: 0
      minutes: 30
      seconds: 0
    above: 45
    alias: Средняя влажность больше 45% в течении 30 минут
condition:
  - condition: state
    entity_id: fan.deerma_jsq2w_30e8_fan_level
    state: "on"
    alias: Проверяем, работает ли увлажнитель
action:
  - service: xiaomi_miot.set_miot_property
    data:
      siid: 2
      piid: 5
      value: 1
      entity_id: humidifier.deerma_jsq2w_30e8_humidifier
    alias: Устанавливаем минимальный режим
mode: single
@washdoc
Copy link

washdoc commented Oct 3, 2023

Времени доброго. Спасибо за настройки карточки. От себя добавлю настройку ползунка выбора влажности и датчика наличии воды в Xiaomi Smart Humidifier 2 (deerma.humidifier.jsq2w) через Xiaomi Miot Auto.
Для ползунка можно просто добавить в карточку:

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

Но ползунок обладает некоторой инерцией на обновление состояния и, бывает, отпрыгивает на предыдущее значение, хотя выставленное значение устанавливается сразу. Поэтому поменяем местами сущности fan и humidifier, так же добавим датчик наличии воды:

type: custom:mini-humidifier
entity: humidifier.deerma_humidifier
model: deerma.humidifier.jsq2w
secondary_info:
  type: mode
name: Увлажнитель
target_humidity:
  icon: mdi:water
  state:
    attribute: humidity
  unit: '%'
  hide: false
  disabled: false
  min: 40
  max: 70
  step: 1
  change_action: >
    (selected, state, entity) => { const options = { entity_id:
    entity.entity_id, humidity: selected }; return
    this.call_service('humidifier', 'set_humidity', options); }
power:
  type: button
  state:
    entity: fan.deerma_fan_level
  toggle_action: |
    (state, entity) => {
      const service = state === 'on' ? 'turn_off' : 'turn_on';
      const options = { entity_id: entity.entity_id };
      return this.call_service('fan', service, options);
    }
indicators:
  humid:
    icon: mdi:water-percent
    unit: '%'
    source:
      entity: sensor.deerma_humidity
    tap_action:
      action: more-info
      entity: sensor.deerma_humidity
  temp:
    icon: mdi:thermometer-low
    unit: °C
    source:
      entity: sensor.deerma_temperature
    tap_action:
      action: more-info
      entity: sensor.deerma_temperature
  water:
    icon:
      template: |
        (value) => {
          if (value === 'off')
            return 'mdi:cup';

          if (value = 'on')
            return 'mdi:cup-outline';
        }
      style: |
        (value) => {
          if (value === 'off')
            return { color: 'green' };

          if (value = 'on')
            return { color: 'red' };

          return {};
        }
    source:
      entity: water_shortage_fault
    tap_action:
      action: more-info
      entity: water_shortage_fault
buttons:
  mode:
    icon: mdi:fan
    order: 1
    type: dropdown
    state:
      entity: fan.deerma_fan_level
      attribute: preset_mode
    source:
      Level1: Тихо
      Level2: Средне
      Level3: Высоко
      Level4: Авто
    active: (state, entity) => (entity.state !== 'off')
    disabled: (state, entity) => (entity.attributes.depth === 0)
    change_action: |
      (selected, state, entity) => {
        const options = { entity_id: entity.entity_id, preset_mode: selected };
        return this.call_service('fan', 'set_preset_mode', options);
      }
  led:
    icon: mdi:lightbulb-on-outline
    order: 2
    type: button
    state:
      entity: light.deerma_light
    toggle_action: |
      (state, entity) => {
        const service = state === 'on' ? 'turn_off' : 'turn_on';
        const options = { entity_id: entity.entity_id };
        return this.call_service('light', service, options);
      }
  buzzer:
    icon: mdi:bell-outline
    order: 3
    state:
      entity: switch.deerma_alarm
    toggle_action: |
      (state, entity) => {
        const service = state === 'on' ? 'turn_off' : 'turn_on';
        const options = { entity_id: entity.entity_id };
        return this.call_service('switch', service, options);
      }

1
Кастомные датчики наличия воды и бачка добавляются в configuration.yaml:

xiaomi_miot:
  device_customizes:
    deerma.humidifier.jsq2w:
      exclude_miot_services: null
      binary_sensor_properties: the_tank_filed,water_shortage_fault
      miot_type: urn:miot-spec-v2:device:humidifier:0000A00E:deerma-jsq2w:1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants