7
7
import pytz
8
8
from datetime import datetime
9
9
from homeassistant .components .sensor import (
10
- STATE_CLASS_MEASUREMENT ,
11
- STATE_CLASS_TOTAL_INCREASING ,
10
+ SensorStateClass ,
12
11
SensorDeviceClass ,
13
- SensorEntityDescription ,
12
+ SensorEntityDescription
14
13
)
15
14
from homeassistant .const import (
16
- ELECTRIC_CURRENT_AMPERE ,
17
- ELECTRIC_POTENTIAL_VOLT ,
18
- FREQUENCY_HERTZ ,
19
- POWER_KILO_WATT , UnitOfEnergy ,
15
+ UnitOfEnergy ,UnitOfPower ,UnitOfFrequency ,UnitOfElectricCurrent ,UnitOfElectricPotential
20
16
)
21
17
from homeassistant .helpers .entity import EntityCategory
22
18
@@ -102,7 +98,7 @@ def map_state_to_datetime(value, key, index) -> str:
102
98
attribute = "activePower" ,
103
99
initial_value = 0 ,
104
100
device_class = SensorDeviceClass .POWER ,
105
- native_unit_of_measurement = POWER_KILO_WATT ,
101
+ native_unit_of_measurement = UnitOfPower . KILO_WATT ,
106
102
entity_category = EntityCategory .DIAGNOSTIC ,
107
103
entity_registry_enabled_default = True ,
108
104
disabled = False ,
@@ -115,7 +111,7 @@ def map_state_to_datetime(value, key, index) -> str:
115
111
attribute = "lastMeterValue" ,
116
112
initial_value = 0 ,
117
113
device_class = SensorDeviceClass .ENERGY ,
118
- state_class = STATE_CLASS_TOTAL_INCREASING ,
114
+ state_class = SensorStateClass . TOTAL_INCREASING ,
119
115
native_unit_of_measurement = UnitOfEnergy .KILO_WATT_HOUR ,
120
116
entity_category = EntityCategory .DIAGNOSTIC ,
121
117
entity_registry_enabled_default = True ,
@@ -128,7 +124,7 @@ def map_state_to_datetime(value, key, index) -> str:
128
124
state = extract_json_amperage_kilo_watts ,
129
125
attribute = "effectiveAmperageLimit" ,
130
126
device_class = SensorDeviceClass .POWER ,
131
- native_unit_of_measurement = POWER_KILO_WATT ,
127
+ native_unit_of_measurement = UnitOfPower . KILO_WATT ,
132
128
entity_category = EntityCategory .DIAGNOSTIC ,
133
129
entity_registry_enabled_default = True ,
134
130
disabled = False ,
@@ -168,8 +164,8 @@ def map_state_to_datetime(value, key, index) -> str:
168
164
state = extract_json_float ,
169
165
attribute = "frequency" ,
170
166
icon = "mdi:current-ac" ,
171
- native_unit_of_measurement = FREQUENCY_HERTZ ,
172
- state_class = STATE_CLASS_MEASUREMENT ,
167
+ native_unit_of_measurement = UnitOfFrequency . HERTZ ,
168
+ state_class = SensorStateClass . MEASUREMENT ,
173
169
entity_category = EntityCategory .DIAGNOSTIC ,
174
170
entity_registry_enabled_default = False ,
175
171
disabled = False ,
@@ -182,8 +178,8 @@ def map_state_to_datetime(value, key, index) -> str:
182
178
attribute = "voltage" ,
183
179
attribute_index = 0 ,
184
180
device_class = SensorDeviceClass .VOLTAGE ,
185
- native_unit_of_measurement = ELECTRIC_POTENTIAL_VOLT ,
186
- state_class = STATE_CLASS_MEASUREMENT ,
181
+ native_unit_of_measurement = UnitOfElectricPotential . VOLT ,
182
+ state_class = SensorStateClass . MEASUREMENT ,
187
183
entity_category = EntityCategory .DIAGNOSTIC ,
188
184
entity_registry_enabled_default = False ,
189
185
disabled = False ,
@@ -196,8 +192,8 @@ def map_state_to_datetime(value, key, index) -> str:
196
192
attribute = "voltage" ,
197
193
attribute_index = 1 ,
198
194
device_class = SensorDeviceClass .VOLTAGE ,
199
- native_unit_of_measurement = ELECTRIC_POTENTIAL_VOLT ,
200
- state_class = STATE_CLASS_MEASUREMENT ,
195
+ native_unit_of_measurement = UnitOfElectricPotential . VOLT ,
196
+ state_class = SensorStateClass . MEASUREMENT ,
201
197
entity_category = EntityCategory .DIAGNOSTIC ,
202
198
entity_registry_enabled_default = False ,
203
199
disabled = False ,
@@ -210,8 +206,8 @@ def map_state_to_datetime(value, key, index) -> str:
210
206
attribute = "voltage" ,
211
207
attribute_index = 2 ,
212
208
device_class = SensorDeviceClass .VOLTAGE ,
213
- native_unit_of_measurement = ELECTRIC_POTENTIAL_VOLT ,
214
- state_class = STATE_CLASS_MEASUREMENT ,
209
+ native_unit_of_measurement = UnitOfElectricPotential . VOLT ,
210
+ state_class = SensorStateClass . MEASUREMENT ,
215
211
entity_category = EntityCategory .DIAGNOSTIC ,
216
212
entity_registry_enabled_default = False ,
217
213
disabled = False ,
@@ -224,8 +220,8 @@ def map_state_to_datetime(value, key, index) -> str:
224
220
attribute = "amperage" ,
225
221
attribute_index = 0 ,
226
222
device_class = SensorDeviceClass .CURRENT ,
227
- native_unit_of_measurement = ELECTRIC_CURRENT_AMPERE ,
228
- state_class = STATE_CLASS_MEASUREMENT ,
223
+ native_unit_of_measurement = UnitOfElectricCurrent . AMPERE ,
224
+ state_class = SensorStateClass . MEASUREMENT ,
229
225
entity_category = EntityCategory .DIAGNOSTIC ,
230
226
entity_registry_enabled_default = False ,
231
227
disabled = False ,
@@ -238,8 +234,8 @@ def map_state_to_datetime(value, key, index) -> str:
238
234
attribute = "amperage" ,
239
235
attribute_index = 1 ,
240
236
device_class = SensorDeviceClass .CURRENT ,
241
- native_unit_of_measurement = ELECTRIC_CURRENT_AMPERE ,
242
- state_class = STATE_CLASS_MEASUREMENT ,
237
+ native_unit_of_measurement = UnitOfElectricCurrent . AMPERE ,
238
+ state_class = SensorStateClass . MEASUREMENT ,
243
239
entity_category = EntityCategory .DIAGNOSTIC ,
244
240
entity_registry_enabled_default = False ,
245
241
disabled = False ,
@@ -252,8 +248,8 @@ def map_state_to_datetime(value, key, index) -> str:
252
248
attribute = "amperage" ,
253
249
attribute_index = 2 ,
254
250
device_class = SensorDeviceClass .CURRENT ,
255
- native_unit_of_measurement = ELECTRIC_CURRENT_AMPERE ,
256
- state_class = STATE_CLASS_MEASUREMENT ,
251
+ native_unit_of_measurement = UnitOfElectricCurrent . AMPERE ,
252
+ state_class = SensorStateClass . MEASUREMENT ,
257
253
entity_category = EntityCategory .DIAGNOSTIC ,
258
254
entity_registry_enabled_default = False ,
259
255
disabled = False ,
0 commit comments