@@ -40,7 +40,7 @@ async def main(args):
40
40
await run_show_sensors (args .host , args .uuid )
41
41
42
42
elif args .action == "show-sensor" :
43
- await run_show_sensor (args .host , args .uuid , args .sensor )
43
+ await run_show_sensor (args .host , args .uuid , args .sensor , args . follow )
44
44
45
45
elif args .action == "get-property" :
46
46
await run_get_property (args .host , args .uuid , args .node_id , args .unit , args .subunit , args .property_id , args .property_type )
@@ -190,7 +190,7 @@ def sensor_callback(sensor, value):
190
190
await comfoconnect .disconnect ()
191
191
192
192
193
- async def run_show_sensor (host : str , uuid : str , sensor : int ):
193
+ async def run_show_sensor (host : str , uuid : str , sensor : int , follow = False ):
194
194
"""Connect to a bridge."""
195
195
result = Future ()
196
196
@@ -201,7 +201,9 @@ async def run_show_sensor(host: str, uuid: str, sensor: int):
201
201
202
202
def sensor_callback (sensor_ , value ):
203
203
"""Print sensor update."""
204
- result .set_result (value )
204
+ print (value )
205
+ if not result .done ():
206
+ result .set_result (value )
205
207
206
208
# Connect to the bridge
207
209
comfoconnect = ComfoConnect (bridges [0 ].host , bridges [0 ].uuid , sensor_callback = sensor_callback )
@@ -219,7 +221,16 @@ def sensor_callback(sensor_, value):
219
221
await comfoconnect .register_sensor (SENSORS [sensor ])
220
222
221
223
# Wait for value
222
- print (await result )
224
+ await result
225
+
226
+ # Follow for updates if requested
227
+ if follow :
228
+ try :
229
+ while True :
230
+ await asyncio .sleep (1 )
231
+
232
+ except KeyboardInterrupt :
233
+ pass
223
234
224
235
# Disconnect
225
236
await comfoconnect .disconnect ()
@@ -277,6 +288,7 @@ async def run_get_property(host: str, uuid: str, node_id: int, unit: int, subuni
277
288
p_sensor .add_argument ("sensor" , help = "The ID of the sensor" , type = int )
278
289
p_sensor .add_argument ("--host" , help = "Host address of the bridge" )
279
290
p_sensor .add_argument ("--uuid" , help = "UUID of this app" , default = DEFAULT_UUID )
291
+ p_sensor .add_argument ("--follow" , "-f" , help = "Follow" , default = False , action = "store_true" )
280
292
281
293
p_sensor = subparsers .add_parser ("get-property" , help = "show a property value" )
282
294
p_sensor .add_argument ("unit" , help = "The Unit of the property" , type = int )
0 commit comments