2
2
3
3
import logging
4
4
5
- from homeassistant .helpers .update_coordinator import CoordinatorEntity
5
+ from homeassistant .config_entries import ConfigEntry
6
+ from homeassistant .helpers .update_coordinator import (
7
+ CoordinatorEntity ,
8
+ DataUpdateCoordinator ,
9
+ )
6
10
7
11
from .const import (
8
12
ATTRIBUTION ,
18
22
19
23
20
24
class MhEntity (CoordinatorEntity ):
21
- def __init__ (self , coordinator , config_entry ):
25
+ def __init__ (
26
+ self ,
27
+ coordinator : DataUpdateCoordinator ,
28
+ config_entry : ConfigEntry ,
29
+ ):
22
30
super ().__init__ (coordinator )
23
31
self .config_entry = config_entry
24
32
25
33
@property
26
- def unique_id (self ):
27
- """Return a unique ID to use for this entity."""
34
+ def unique_id (self ) -> str :
28
35
return self .config_entry .entry_id
29
36
30
37
@property
@@ -42,24 +49,23 @@ def device_info(self) -> dict:
42
49
return info
43
50
44
51
@property
45
- def _mh_dev_name_suffix (self ):
52
+ def _mh_dev_name_suffix (self ) -> str :
46
53
return ""
47
54
48
55
@property
49
- def _mh_identifiers (self ):
56
+ def _mh_identifiers (self ) -> tuple :
50
57
return (DOMAIN , self .config_entry .entry_id )
51
58
52
59
@property
53
- def _mh_via_device (self ):
60
+ def _mh_via_device (self ) -> tuple :
54
61
return (DOMAIN , self .config_entry .entry_id )
55
62
56
63
@property
57
64
def _mh_name (self ) -> str :
58
65
return self .config_entry .data .get (CONF_NAME , DEFAULT_NAME )
59
66
60
67
@property
61
- def device_state_attributes (self ):
62
- """Return the state attributes."""
68
+ def device_state_attributes (self ) -> dict :
63
69
return {
64
70
"attribution" : ATTRIBUTION ,
65
71
"id" : str (self .config_entry .data .get (CONF_DEVICE_ID )),
@@ -74,27 +80,30 @@ class MhHeaterEntity(MhEntity):
74
80
heater_name : str = ""
75
81
heater_id : int = 0
76
82
77
- def __init__ (self , coordinator , config_entry , heater : dict ):
83
+ def __init__ (
84
+ self ,
85
+ coordinator : DataUpdateCoordinator ,
86
+ config_entry : ConfigEntry ,
87
+ heater : dict ,
88
+ ):
78
89
super ().__init__ (coordinator , config_entry )
79
90
self .heater_name = heater ["name" ]
80
91
self .heater_id = heater ["id" ]
81
92
82
93
@property
83
- def name (self ):
84
- """Return the name of the sensor."""
94
+ def name (self ) -> str :
85
95
return f"{ self ._mh_name } { self .heater_name } { ' ' + self ._key if self ._key else '' } "
86
96
87
97
@property
88
- def unique_id (self ):
89
- """Return a unique ID to use for this entity."""
98
+ def unique_id (self ) -> str :
90
99
return f"{ super ().unique_id } htr{ self .heater_id } { self ._key if self ._key else '' } "
91
100
92
101
@property
93
- def _mh_dev_name_suffix (self ):
102
+ def _mh_dev_name_suffix (self ) -> str :
94
103
return f" { self .heater_name } "
95
104
96
105
@property
97
- def _mh_identifiers (self ):
106
+ def _mh_identifiers (self ) -> tuple :
98
107
return (DOMAIN , f"{ super ().unique_id } htr{ self .heater_id } " )
99
108
100
109
def get_heater (self ) -> dict :
@@ -117,32 +126,33 @@ class MhEnvEntity(MhEntity):
117
126
env_name : str = ""
118
127
env_id : int = 0
119
128
120
- def __init__ (self , coordinator , config_entry , env : dict ):
129
+ def __init__ (
130
+ self ,
131
+ coordinator : DataUpdateCoordinator ,
132
+ config_entry : ConfigEntry ,
133
+ env : dict ,
134
+ ):
121
135
super ().__init__ (coordinator , config_entry )
122
136
self .env_name = env ["name" ]
123
137
self .env_id = env ["id" ]
124
138
125
139
@property
126
- def name (self ):
127
- """Return the name of the sensor."""
140
+ def name (self ) -> str :
128
141
return f"{ self ._mh_name } { self .env_name } { ' ' + self ._key if self ._key else '' } "
129
142
130
143
@property
131
- def unique_id (self ):
132
- """Return a unique ID to use for this entity."""
144
+ def unique_id (self ) -> str :
133
145
return f"{ super ().unique_id } env{ self .env_id } { self ._key if self ._key else '' } "
134
146
135
147
@property
136
- def _mh_dev_name_suffix (self ):
148
+ def _mh_dev_name_suffix (self ) -> str :
137
149
return f" { self .env_name } "
138
150
139
151
@property
140
- def _mh_identifiers (self ):
152
+ def _mh_identifiers (self ) -> tuple :
141
153
return (DOMAIN , f"{ super ().unique_id } env{ self .env_id } " )
142
154
143
- def get_env (
144
- self ,
145
- ) -> dict :
155
+ def get_env (self ) -> dict :
146
156
"""Return env state data"""
147
157
if not self .coordinator .data .get ("dataActual" , False ):
148
158
_logger .warninig ("data not actual! %s" , self .coordinator .data )
@@ -162,32 +172,33 @@ class MhEngEntity(MhEntity):
162
172
eng_name : str = ""
163
173
eng_id : int = 0
164
174
165
- def __init__ (self , coordinator , config_entry , eng : dict ):
175
+ def __init__ (
176
+ self ,
177
+ coordinator : DataUpdateCoordinator ,
178
+ config_entry : ConfigEntry ,
179
+ eng : dict ,
180
+ ):
166
181
super ().__init__ (coordinator , config_entry )
167
182
self .eng_name = eng ["name" ]
168
183
self .eng_id = eng ["id" ]
169
184
170
185
@property
171
186
def name (self ):
172
- """Return the name of the sensor."""
173
187
return f"{ self ._mh_name } { self .eng_name } { ' ' + self ._key if self ._key else '' } "
174
188
175
189
@property
176
190
def unique_id (self ):
177
- """Return a unique ID to use for this entity."""
178
191
return f"{ super ().unique_id } eng{ self .eng_id } { self ._key if self ._key else '' } "
179
192
180
193
@property
181
- def _mh_dev_name_suffix (self ):
194
+ def _mh_dev_name_suffix (self ) -> str :
182
195
return f" { self .eng_name } "
183
196
184
197
@property
185
- def _mh_identifiers (self ):
198
+ def _mh_identifiers (self ) -> tuple :
186
199
return (DOMAIN , f"{ super ().unique_id } eng{ self .eng_id } " )
187
200
188
- def get_eng (
189
- self ,
190
- ) -> dict :
201
+ def get_eng (self ) -> dict :
191
202
"""Return eng state data"""
192
203
if not self .coordinator .data .get ("dataActual" , False ):
193
204
_logger .warninig ("data not actual! %s" , self .coordinator .data )
0 commit comments