Skip to content

Commit 9628baf

Browse files
committed
Check tariff structure presence
1 parent 5f7850e commit 9628baf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

custom_components/plugwise-beta/sensor.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,16 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
160160
if sensor in data:
161161
if data[sensor] is not None:
162162
if "power" in device["types"]:
163-
if (
164-
"off" in sensor
165-
and api._power_tariff[
166-
"electricity_consumption_tariff_structure"
167-
]
168-
== "single"
169-
):
170-
continue
163+
if "off" in sensor:
164+
api._power_tariff is None:
165+
continue
166+
if (
167+
api._power_tariff[
168+
"electricity_consumption_tariff_structure"
169+
]
170+
== "single"
171+
):
172+
continue
171173
devices.append(
172174
PwPowerSensor(
173175
api,

0 commit comments

Comments
 (0)