piww 发表于 2024-2-18 21:14:09

Number实体接入homekit

如何把number.145790a8b46c_targettemp数字实体桥接到homekit呢?我有个海尔热水器,现在接入了ha,设置温度是个数字实体,怎么把它接入homekit呢,能在homekit也设置温度

leung 发表于 2024-2-19 01:54:54

homekit不支持number类型,你可能要把它转换成water_heater,再通过homebridge接入就能正确识别,https://www.home-assistant.io/integrations/water_heater

piww 发表于 2024-2-19 08:57:51

leung 发表于 2024-2-19 01:54
homekit不支持number类型,你可能要把它转换成water_heater,再通过homebridge接入就能正确识别,https://w ...

能具体点吗?没看得懂要怎么配置

leung 发表于 2024-3-4 21:19:21

piww 发表于 2024-2-19 08:57
能具体点吗?没看得懂要怎么配置

https://bbs.hassbian.com/thread-22202-2-1.html
找到办法了,按照14#楼的代码就可以生成一个新的climate实体,用这个接入homekit即可

piww 发表于 2024-3-5 13:45:22

我现在用这个方式实现:
climate:
- platform: climate_template
    name: 水温
    modes:
      - "auto"
    unique_id: Water_Template
    min_temp: 35
    max_temp: 60

    temp_step: 1
    current_temperature_template: "{{ states('number.145790a8b46c_targettemp') }}"
    target_temperature_template: "{{ states('number.145790a8b46c_targettemp') }}"

    set_temperature:
      service: number.set_value
      target:
      entity_id: number.145790a8b46c_targettemp
      data:
      value: "{{ temperature }}"   



但现在发现个问题,这里设置的步长是1,在homekit里,他的步长是0.5 ,我用语音控制水温提升至XX度,他都会把他设置成35度,给位的是这样的情况吗?怎么解决呢?

leung 发表于 2024-3-5 17:18:40

piww 发表于 2024-3-5 13:45
我现在用这个方式实现:
climate:
- platform: climate_template


我贴出来的方法试了下,虽然设定温度步长为1,但homekit也会变成0.5,再研究研究

leung 发表于 2024-3-7 16:18:06

piww 发表于 2024-3-5 13:45
我现在用这个方式实现:
climate:
- platform: climate_template


对了,你这个不能实现关闭热水器吧?

piww 发表于 2024-3-8 11:36:12

leung 发表于 2024-3-7 16:18
对了,你这个不能实现关闭热水器吧?

应该是可以,用modes做映射把,我猜的

leung 发表于 2024-3-8 20:49:14

piww 发表于 2024-3-8 11:36
应该是可以,用modes做映射把,我猜的

我试了不行,得set_hvac_mode
climate:
- platform: climate_template
    name: miji_smart_water_heating
    modes:
      - "heat"
      - "off"
    unique_id: miji_smart_water_heating
    min_temp: 25
    max_temp: 55
    temp_step: 1
    precision: 1
    current_temperature_template: "{{ states('sensor.xiaomi_mj2_9513_temperature') }}"
    target_temperature_template: "{{ states('number.xiaomi_mj2_9513_target_temperature') }}"
    hvac_mode_template: >
      {% if is_state('switch.xiaomi_mj2_9513_electric_blanket', 'on') %}
      heat
      {% else %}
      off
      {% endif %}
    set_temperature:
      service: number.set_value
      target:
      entity_id: number.xiaomi_mj2_9513_target_temperature
      data:
      value: "{{ temperature }}"
    set_hvac_mode:
    - choose:
      - conditions:
          - condition: template
            value_template: "{{ hvac_mode == 'off' }}"
      sequence:
          - service: switch.turn_off
            target:
            entity_id: switch.xiaomi_mj2_9513_electric_blanket
      - conditions:
          - condition: template
            value_template: "{{ hvac_mode == 'heat' }}"
      sequence:
          - service: switch.turn_on
            target:
            entity_id: switch.xiaomi_mj2_9513_electric_blanket
          - service: number.set_value
            target:
            entity_id: number.xiaomi_mj2_9513_target_temperature
            data:
            value: "{{ temperature }}"
页: [1]
查看完整版本: Number实体接入homekit