- 积分
- 118
- 金钱
- 104
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
注册会员
- 积分
- 118
- 金钱
- 104
- HASS币
- 0
|
发表于 2021-3-16 18:17:45
|
显示全部楼层
sensor:
- platform: xiaomi_miio_raw
name: smart_plug
host: 192.168.x.x
token: xxxxxxxxxx
max_properties: 10
default_properties_getter: get_properties
default_properties:
- "{'did': 'power', 'piid': 1, 'siid': 2}"
- "{'did': 'temperature', 'piid': 6, 'siid': 2}"
- "{'did': 'indicator_light', 'piid': 1, 'siid': 3}"
- "{'did': 'on_duration', 'piid': 1, 'siid': 4}"
- "{'did': 'off_duration', 'piid': 2, 'siid': 4}"
- "{'did': 'countdown', 'piid': 3, 'siid': 4}"
- "{'did': 'task_switch', 'piid': 4, 'siid': 4}"
- "{'did': 'countdown_info', 'piid': 5, 'siid': 4}"
- "{'did': 'power_consumption', 'piid': 1, 'siid': 5}"
- "{'did': 'electric_current', 'piid': 2, 'siid': 5}"
- "{'did': 'voltage', 'piid': 3, 'siid': 5}"
- "{'did': 'electric_power', 'piid': 6, 'siid': 5}"
- platform: template
sensors:
smart_plug_power:
unique_id: smart_plug_power
unit_of_measurement: W
value_template: "{{ state_attr('sensor.smart_plug', 'electric_power')/100 }}"
availability_template: "{{ not is_state('sensor.smart_plug', 'unavailable') }}"
icon_template: "mdi:flash"
switch:
- platform: template
switches:
smart_plug_switch:
unique_id: smart_plug_switch
value_template: "{{ state_attr('sensor.smart_plug', 'power') }}"
availability_template: "{{ not is_state('sensor.smart_plug', 'unavailable') }}"
turn_on:
service: xiaomi_miio_raw.sensor_raw_command
data:
entity_id: sensor.smart_plug
method: set_properties
params:
- did: power
siid: 2
piid: 1
value: true
turn_off:
service: xiaomi_miio_raw.sensor_raw_command
data:
entity_id: sensor.smart_plug
method: set_properties
params:
- did: power
siid: 2
piid: 1
value: false |
|