fix #20387 devices without model/protocol (#20530)

This commit is contained in:
Fredrik Erlandsson 2019-01-29 01:46:37 +01:00 committed by Paulus Schoutsen
parent 34090bd021
commit 717a0c2b2d

View file

@ -116,10 +116,17 @@ class TelldusLiveEntity(Entity):
def device_info(self):
"""Return device info."""
device = self._client.device_info(self.device.device_id)
return {
device_info = {
'identifiers': {('tellduslive', self.device.device_id)},
'name': self.device.name,
'model': device['model'].title(),
'manufacturer': device['protocol'].title(),
'via_hub': ('tellduslive', device.get('client')),
}
model = device.get('model')
if model is not None:
device_info['model'] = model.title()
protocol = device.get('protocol')
if protocol is not None:
device_info['manufacturer'] = protocol.title()
client = device.get('client')
if client is not None:
device_info['via_hub'] = ('tellduslive', client)
return device_info