-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfiguration.yaml
132 lines (127 loc) · 4.05 KB
/
configuration.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
input_boolean:
govee_heater_1_state:
name: "Govee Heater 1 State"
icon: mdi:radiator
# govee_heater_2_state:
# name: "Govee Heater 2 State"
# icon: mdi:radiator
rest_command:
govee_appliance_request:
url: https://openapi.api.govee.com/router/api/v1/device/control
method: POST
headers:
Content-Type: application/json
Govee-API-Key: !secret govee_api_key
content_type: "application/json; charset=utf-8"
payload: >-
{
"requestId": "{{ requestId }}",
"payload": {
"sku": "{{ sku }}",
"device": "{{ device }}",
"capability": {
"type": "{{ capability_type }}",
"instance": "{{ capability_instance }}",
"value": {{ capability_value }}
}
}
}
govee_device_state:
url: https://openapi.api.govee.com/router/api/v1/device/state
method: POST
headers:
Content-Type: application/json
Govee-API-Key: !secret govee_api_key
content_type: "application/json; charset=utf-8"
payload: >-
{
"requestId": "{{ requestId }}",
"payload": {
"sku": "{{ sku }}",
"device": "{{ device }}"
}
}
switch:
- platform: template
switches:
govee_heater_1_toggle:
value_template: '{{ states("input_boolean.govee_heater_1_state") }}'
friendly_name: "Govee Heater 1"
turn_on:
- service: script.govee_heater_1_on
turn_off:
- service: script.govee_heater_1_off
icon_template: >-
{% if is_state('input_boolean.govee_heater_1_state', 'on') %} mdi:radiator
{% else %} mdi:radiator-off
{% endif %}
# govee_heater_2_toggle:
# value_template: '{{ states("input_boolean.govee_heater_2_state") }}'
# friendly_name: "Govee Heater 2"
# turn_on:
# - service: script.govee_heater_2_on
# turn_off:
# - service: script.govee_heater_2_off
# icon_template: >-
# {% if is_state('input_boolean.govee_heater_2_state', 'on') %} mdi:radiator
# {% else %} mdi:radiator-off
# {% endif %}
sensor:
- platform: rest
name: "Govee Heater 1 API State"
method: POST
resource: https://openapi.api.govee.com/router/api/v1/device/state
headers:
Content-Type: application/json
Govee-API-Key: !secret govee_api_key
payload: >-
{
"requestId": "1_4",
"payload": {
"sku": "H7131",
"device": !secret govee_heater_1_device
}
}
value_template: >-
{% if value_json is defined and value_json.payload is defined and value_json.payload.capabilities is defined %}
{% set power = value_json.payload.capabilities | selectattr('instance', 'equalto', 'powerSwitch') | map(attribute='state') | map(attribute='value') | first | default(0) %}
{{ power }}
{% else %}
0
{% endif %}
scan_interval: 30
force_update: true
json_attributes_path: "$.payload.capabilities"
json_attributes:
- instance
- type
- state
# - platform: rest
# name: "Govee Heater 2 API State"
# method: POST
# resource: https://openapi.api.govee.com/router/api/v1/device/state
# headers:
# Content-Type: application/json
# Govee-API-Key: !secret govee_api_key
# payload: >-
# {
# "requestId": "2_4",
# "payload": {
# "sku": "H7131",
# "device": !secret govee_heater_2_device
# }
# }
# value_template: >-
# {% if value_json is defined and value_json.payload is defined and value_json.payload.capabilities is defined %}
# {% set power = value_json.payload.capabilities | selectattr('instance', 'equalto', 'powerSwitch') | map(attribute='state') | map(attribute='value') | first | default(0) %}
# {{ power }}
# {% else %}
# 0
# {% endif %}
# scan_interval: 30
# force_update: true
# json_attributes_path: "$.payload.capabilities"
# json_attributes:
# - instance
# - type
# - state