Fix an Ambient PWS exception when location info is missing (#21220)

pull/21238/head
Aaron Bach 2019-02-20 04:10:42 -07:00 committed by Paulus Schoutsen
parent 9057da01bd
commit be26fc896d
1 changed files with 4 additions and 2 deletions

View File

@ -339,8 +339,10 @@ class AmbientStation:
self.stations[station['macAddress']] = {
ATTR_LAST_DATA: station['lastData'],
ATTR_LOCATION: station['info']['location'],
ATTR_NAME: station['info']['name'],
ATTR_LOCATION: station.get('info', {}).get('location'),
ATTR_NAME:
station.get('info', {}).get(
'name', station['macAddress']),
}
for component in ('binary_sensor', 'sensor'):