24
24
25
25
26
26
async def async_setup_entry (hass , config_entry , async_add_entities ):
27
- """Set up the number platform."""
27
+ """Set up the time platform."""
28
28
29
29
async def async_discover (config , connection ):
30
30
await _async_setup_entity (hass , config , async_add_entities , connection )
@@ -37,27 +37,31 @@ async def async_discover(config, connection):
37
37
38
38
39
39
async def _async_setup_entity (hass , config , async_add_entities , connection ):
40
- """Set up the Node-RED number ."""
40
+ """Set up the Node-RED time ."""
41
41
42
- async_add_entities ([NodeRedNumber (hass , config , connection )])
42
+ async_add_entities ([NodeRedTime (hass , config , connection )])
43
43
44
44
45
45
def _convert_string_to_time (value ):
46
46
"""Convert string to time."""
47
47
if value is None :
48
48
return None
49
- return parser .parse (value ).time ()
49
+ try :
50
+ return parser .parse (value ).time ()
51
+ except ValueError :
52
+ _LOGGER .error (f"Unable to parse time: { value } " )
53
+ return None
50
54
51
55
52
- class NodeRedNumber (NodeRedEntity , TimeEntity ):
53
- """Node-RED number class."""
56
+ class NodeRedTime (NodeRedEntity , TimeEntity ):
57
+ """Node-RED time class."""
54
58
55
59
_attr_native_value = None
56
60
_bidirectional = True
57
61
_component = CONF_TIME
58
62
59
63
def __init__ (self , hass , config , connection ):
60
- """Initialize the number ."""
64
+ """Initialize the time ."""
61
65
super ().__init__ (hass , config )
62
66
self ._message_id = config [CONF_ID ]
63
67
self ._connection = connection
0 commit comments