handle missing friendly name

This commit is contained in:
Jon Maddox
2015-09-14 00:14:02 -04:00
parent a6d61cc93a
commit 167a983068

View File

@@ -97,7 +97,11 @@ function HomeAssistantAccessory(log, data, client) {
// device info
this.data = data
this.entity_id = data.entity_id
if (data.attributes && data.attributes.friendly_name) {
this.name = data.attributes.friendly_name
}else{
this.name = data.entity_id.split('.').pop().replace(/_/g, ' ')
}
this.client = client
this.log = log;