Skip to content

Commit 60444ce

Browse files
committed
remove unnecessary api_attribute dependency in number.py
implement sense configuration
1 parent d9c813a commit 60444ce

File tree

5 files changed

+145
-7
lines changed

5 files changed

+145
-7
lines changed

custom_components/plugwise_usb/number.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class PlugwiseNumberEntityDescription(
3232
):
3333
"""Describes Plugwise Number entity."""
3434

35-
api_attribute: str = ""
3635
async_number_fn: str = ""
3736

3837

@@ -47,7 +46,6 @@ class PlugwiseNumberEntityDescription(
4746
native_unit_of_measurement=UnitOfTime.MINUTES,
4847
native_max_value=255,
4948
native_min_value=1,
50-
api_attribute="reset_timer",
5149
),
5250
PlugwiseNumberEntityDescription(
5351
key="maintenance_interval",
@@ -59,7 +57,6 @@ class PlugwiseNumberEntityDescription(
5957
native_unit_of_measurement=UnitOfTime.MINUTES,
6058
native_max_value=1440,
6159
native_min_value=5,
62-
api_attribute="maintenance_interval",
6360
),
6461
PlugwiseNumberEntityDescription(
6562
key="sleep_duration",
@@ -71,7 +68,6 @@ class PlugwiseNumberEntityDescription(
7168
entity_category=EntityCategory.CONFIG,
7269
native_max_value=1440,
7370
native_min_value=60,
74-
api_attribute="sleep_duration",
7571
),
7672
PlugwiseNumberEntityDescription(
7773
key="awake_duration",
@@ -83,7 +79,6 @@ class PlugwiseNumberEntityDescription(
8379
entity_category=EntityCategory.CONFIG,
8480
native_max_value=60,
8581
native_min_value=1,
86-
api_attribute="awake_duration",
8782
),
8883
PlugwiseNumberEntityDescription(
8984
key="clock_interval",
@@ -95,7 +90,46 @@ class PlugwiseNumberEntityDescription(
9590
native_unit_of_measurement=UnitOfTime.MINUTES,
9691
native_max_value=65535,
9792
native_min_value=1,
98-
api_attribute="clock_interval",
93+
),
94+
PlugwiseNumberEntityDescription(
95+
key="humidity_upper_bound",
96+
translation_key="sense_humidity_upper_bound",
97+
async_number_fn="set_hysteresis_humidity_upper_bound",
98+
node_feature=NodeFeature.SENSE_HYSTERESIS,
99+
entity_category=EntityCategory.CONFIG,
100+
device_class=NumberDeviceClass.HUMIDITY,
101+
native_max_value=99,
102+
native_min_value=1,
103+
),
104+
PlugwiseNumberEntityDescription(
105+
key="humidity_lower_bound",
106+
translation_key="sense_humidity_lower_bound",
107+
async_number_fn="set_hysteresis_humidity_lower_bound",
108+
node_feature=NodeFeature.SENSE_HYSTERESIS,
109+
entity_category=EntityCategory.CONFIG,
110+
device_class=NumberDeviceClass.HUMIDITY,
111+
native_max_value=99,
112+
native_min_value=1,
113+
),
114+
PlugwiseNumberEntityDescription(
115+
key="temperature_upper_bound",
116+
translation_key="sense_temperature_upper_bound",
117+
async_number_fn="set_hysteresis_temperature_upper_bound",
118+
node_feature=NodeFeature.SENSE_HYSTERESIS,
119+
entity_category=EntityCategory.CONFIG,
120+
device_class=NumberDeviceClass.TEMPERATURE,
121+
native_max_value=60,
122+
native_min_value=1,
123+
),
124+
PlugwiseNumberEntityDescription(
125+
key="temperature_lower_bound",
126+
translation_key="sense_temperature_lower_bound",
127+
async_number_fn="set_hysteresis_temperature_lower_bound",
128+
node_feature=NodeFeature.SENSE_HYSTERESIS,
129+
entity_category=EntityCategory.CONFIG,
130+
device_class=NumberDeviceClass.TEMPERATURE,
131+
native_max_value=60,
132+
native_min_value=1,
99133
),
100134
)
101135

@@ -178,7 +212,7 @@ def _handle_coordinator_update(self) -> None:
178212
return
179213
self._attr_native_value = getattr(
180214
self.coordinator.data[self.entity_description.node_feature],
181-
self.entity_description.api_attribute,
215+
self.entity_description.key,
182216
)
183217
self.async_write_ha_state()
184218

custom_components/plugwise_usb/strings.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@
122122
},
123123
"motion_daylight_mode": {
124124
"name": "Daylight mode"
125+
},
126+
"sense_humidity_enabled": {
127+
"name": "Enable humidity switching on hysteresis"
128+
},
129+
"sense_humidity_direction": {
130+
"name": "Switch on or off on increasing or decreasing humidity"
131+
},
132+
"sense_temperature_enabled": {
133+
"name": "Enable temperature switching on hysteresis"
134+
},
135+
"sense_temperature_direction": {
136+
"name": "Switch on or off on increasing or decreasing temperature"
125137
}
126138
},
127139
"number": {
@@ -139,6 +151,18 @@
139151
},
140152
"sed_clock_interval": {
141153
"name": "Clock interval"
154+
},
155+
"sense_humidity_upper_bound": {
156+
"name": "Humidity upper boundary value"
157+
},
158+
"sense_humidity_lower_bound": {
159+
"name": "Humidity lower boundary value"
160+
},
161+
"sense_temperature_upper_bound": {
162+
"name": "Temperature upper boundary value"
163+
},
164+
"sense_temperature_lower_bound": {
165+
"name": "Temperature lower boundary value"
142166
}
143167
},
144168
"button": {

custom_components/plugwise_usb/switch.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,38 @@ class PlugwiseSwitchEntityDescription(
7070
node_feature=NodeFeature.MOTION_CONFIG,
7171
api_attribute="daylight_mode",
7272
),
73+
PlugwiseSwitchEntityDescription(
74+
key="humidity_enabled",
75+
translation_key="sense_humidity_enabled",
76+
async_switch_fn="set_hysteresis_humidity_enabled",
77+
entity_category=EntityCategory.CONFIG,
78+
node_feature=NodeFeature.SENSE_HYSTERESIS,
79+
api_attribute="humidity_enabled",
80+
),
81+
PlugwiseSwitchEntityDescription(
82+
key="humidity_direction",
83+
translation_key="sense_humidity_direction",
84+
async_switch_fn="set_hysteresis_humidity_direction",
85+
entity_category=EntityCategory.CONFIG,
86+
node_feature=NodeFeature.SENSE_HYSTERESIS,
87+
api_attribute="humidity_direction",
88+
),
89+
PlugwiseSwitchEntityDescription(
90+
key="temperature_enabled",
91+
translation_key="sense_temperature_enabled",
92+
async_switch_fn="set_hysteresis_temperature_enabled",
93+
entity_category=EntityCategory.CONFIG,
94+
node_feature=NodeFeature.SENSE_HYSTERESIS,
95+
api_attribute="temperature_enabled",
96+
),
97+
PlugwiseSwitchEntityDescription(
98+
key="temperature_direction",
99+
translation_key="sense_temperature_direction",
100+
async_switch_fn="set_hysteresis_temperature_direction",
101+
entity_category=EntityCategory.CONFIG,
102+
node_feature=NodeFeature.SENSE_HYSTERESIS,
103+
api_attribute="temperature_direction",
104+
),
73105
)
74106

75107

custom_components/plugwise_usb/translations/en.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@
122122
},
123123
"motion_daylight_mode": {
124124
"name": "Daylight mode"
125+
},
126+
"sense_humidity_enabled": {
127+
"name": "Enable humidity switching on hysteresis"
128+
},
129+
"sense_humidity_direction": {
130+
"name": "Switch on or off on increasing or decreasing humidity"
131+
},
132+
"sense_temperature_enabled": {
133+
"name": "Enable temperature switching on hysteresis"
134+
},
135+
"sense_temperature_direction": {
136+
"name": "Switch on or off on increasing or decreasing temperature"
125137
}
126138
},
127139
"number": {
@@ -139,6 +151,18 @@
139151
},
140152
"sed_clock_interval": {
141153
"name": "Clock interval"
154+
},
155+
"sense_humidity_upper_bound": {
156+
"name": "Humidity upper boundary value"
157+
},
158+
"sense_humidity_lower_bound": {
159+
"name": "Humidity lower boundary value"
160+
},
161+
"sense_temperature_upper_bound": {
162+
"name": "Temperature upper boundary value"
163+
},
164+
"sense_temperature_lower_bound": {
165+
"name": "Temperature lower boundary value"
142166
}
143167
},
144168
"button": {

custom_components/plugwise_usb/translations/nl.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@
122122
},
123123
"motion_daylight_mode": {
124124
"name": "Daglichtmodus"
125+
}},
126+
"sense_humidity_enabled": {
127+
"name": "Zet schakelen op luchtvochtigheid hysterese aan"
128+
},
129+
"sense_humidity_direction": {
130+
"name": "Schakel aan of uit bij stijgende luchtvochtigheid"
131+
},
132+
"sense_temperature_enabled": {
133+
"name": "Zet schakelen op temperatuur hysterese aan"
134+
},
135+
"sense_temperature_direction": {
136+
"name": "Schakel aan of uit bij stijgende temperatuur"
125137
}
126138
},
127139
"number": {
@@ -139,6 +151,18 @@
139151
},
140152
"sed_clock_interval": {
141153
"name": "Klokinterval"
154+
},
155+
"sense_humidity_upper_bound": {
156+
"name": "Hoge schakelpunt luchtvochtigheid"
157+
},
158+
"sense_humidity_lower_bound": {
159+
"name": "Lage schakelpunt luchtvochtigheid"
160+
},
161+
"sense_temperature_upper_bound": {
162+
"name": "Hoge schakelpunt temperatuur"
163+
},
164+
"sense_temperature_lower_bound": {
165+
"name": "Lage schakelpunt temperatuur"
142166
}
143167
},
144168
"button": {

0 commit comments

Comments
 (0)