1
1
import asyncio
2
2
import logging
3
3
from enum import Enum
4
+ from typing import Optional
4
5
5
6
from homeassistant .components .sensor import ENTITY_ID_FORMAT
6
7
from homeassistant .core import callback
15
16
DATA_STATE = "state"
16
17
17
18
SENSOR_TYPES = {
18
- "mode" : ["Mode" , None , "mode" , None ],
19
- "menu" : ["Menu" , None , "menu" , None ],
20
- "temperature" : ["Temperature" , None , "temperature" , "°C" ],
21
- "remaining" : ["Remaining" , None , "remaining" , "min" ],
22
- "duration" : ["Duration" , None , "duration" , "min" ],
23
- "favorite" : ["Favorite" , None , "favorite" , None ],
24
- "state" : ["State" , "stage" , "state" , None ],
25
- "rice_id" : ["Rice Id" , "stage" , "rice_id" , None ],
26
- "taste" : ["Taste" , "stage" , "taste" , None ],
27
- "taste_phase" : ["Taste Phase" , "stage" , "taste_phase" , None ],
28
- "stage_name" : ["Stage Name" , "stage" , "name" , None ],
29
- "stage_description" : ["Stage Description" , "stage" , "description" , None ],
19
+ "mode" : ["Mode" , None , "mode" , None , "mdi:bowl" ],
20
+ "menu" : ["Menu" , None , "menu" , None , "mdi:menu" ],
21
+ "temperature" : ["Temperature" , None , "temperature" , "°C" , None ],
22
+ "remaining" : ["Remaining" , None , "remaining" , "min" , "mdi:timer" ],
23
+ "duration" : ["Duration" , None , "duration" , "min" , "mdi:timelapse" ],
24
+ "favorite" : ["Favorite" , None , "favorite" , None , "mdi:information-outline" ],
25
+ "state" : ["State" , "stage" , "state" , None , "mdi:playlist-check" ],
26
+ "rice_id" : ["Rice Id" , "stage" , "rice_id" , None , "mdi:rice" ],
27
+ "taste" : ["Taste" , "stage" , "taste" , None , "mdi:flash-outline" ],
28
+ "taste_phase" : ["Taste Phase" , "stage" , "taste_phase" , None , "mdi:flash-outline" ],
29
+ "stage_name" : ["Stage Name" , "stage" , "name" , None , "mdi:stairs" ],
30
+ "stage_description" : [
31
+ "Stage Description" ,
32
+ "stage" ,
33
+ "description" ,
34
+ None ,
35
+ "mdi:stairs" ,
36
+ ],
30
37
}
31
38
32
39
@@ -53,6 +60,7 @@ def __init__(self, device, host, config):
53
60
self ._child = config [1 ]
54
61
self ._attr = config [2 ]
55
62
self ._unit_of_measurement = config [3 ]
63
+ self ._icon = config [4 ]
56
64
self ._state = None
57
65
58
66
self .entity_id = ENTITY_ID_FORMAT .format (
@@ -117,6 +125,11 @@ def unit_of_measurement(self):
117
125
"""Return the unit of measurement the state is expressed in."""
118
126
return self ._unit_of_measurement
119
127
128
+ @property
129
+ def icon (self ) -> Optional [str ]:
130
+ """Return the icon to use in the frontend, if any."""
131
+ return self ._icon
132
+
120
133
@property
121
134
def should_poll (self ):
122
135
"""Return the polling state."""
0 commit comments