File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
homeassistant_cli/plugins Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ def listcmd(ctx: Configuration, devicefilter: str):
2828 """List all devices from Home Assistant."""
2929 ctx .auto_output ("table" )
3030
31+ areas = api .get_areas (ctx )
32+
3133 devices = api .get_devices (ctx )
3234
3335 result = [] # type: List[Dict]
@@ -40,12 +42,19 @@ def listcmd(ctx: Configuration, devicefilter: str):
4042 if devicefilterre .search (device ['name' ]):
4143 result .append (device )
4244
45+ for device in devices :
46+ area = next (
47+ (a for a in areas if a ['area_id' ] == device ['area_id' ]), None
48+ )
49+ if area :
50+ device ['area_name' ] = area ['name' ]
51+
4352 cols = [
4453 ('ID' , 'id' ),
4554 ('NAME' , 'name' ),
4655 ('MODEL' , 'model' ),
4756 ('MANUFACTURER' , 'manufacturer' ),
48- ('AREA' , 'area_id ' ),
57+ ('AREA' , 'area_name ' ),
4958 ]
5059
5160 ctx .echo (
You can’t perform that action at this time.
0 commit comments