Fix more terrible vscode indentation

This commit is contained in:
Thomas Lovén 2019-12-09 23:31:20 +01:00
parent acf8fd1be1
commit b377a20cf9

View File

@ -37,39 +37,40 @@ export function entity_filter(hass, filter) {
switch(key.split(" ")[0]) { switch(key.split(" ")[0]) {
case "options": case "options":
case "sort": case "sort":
break; break;
case "domain": case "domain":
if(!match(value, entity.entity_id.split('.')[0])) if(!match(value, entity.entity_id.split('.')[0]))
return false; return false;
break; break;
case "entity_id": case "entity_id":
if(!match(value, entity.entity_id)) if(!match(value, entity.entity_id))
return false; return false;
break; break;
case "state": case "state":
if(!match(value, entity.state)) if(!match(value, entity.state))
return false; return false;
break; break;
case "name": case "name":
if(!entity.attributes.friendly_name if(!entity.attributes.friendly_name
|| !match(value, entity.attributes.friendly_name)) || !match(value, entity.attributes.friendly_name)
return false;
break;
case "group":
if(!value.startsWith("group.")
|| !hass.states[value]
|| !hass.states[value].attributes.entity_id
|| !hass.states[value].attributes.entity_id.includes(entity.entity_id)
) )
return false; return false;
break; break;
case "attributes": case "group":
if(!value.startsWith("group.")
|| !hass.states[value]
|| !hass.states[value].attributes.entity_id
|| !hass.states[value].attributes.entity_id.includes(entity.entity_id)
)
return false;
break;
case "attributes":
for(const [k, v] of Object.entries(value)) { for(const [k, v] of Object.entries(value)) {
let attr = k.split(" ")[0]; let attr = k.split(" ")[0];
let entityAttribute = entity.attributes; let entityAttribute = entity.attributes;
@ -80,47 +81,49 @@ export function entity_filter(hass, filter) {
} }
if(entityAttribute === undefined if(entityAttribute === undefined
|| (v && !match(v, entityAttribute)) || (v && !match(v, entityAttribute))
) )
return false; return false;
continue; continue;
}
break;
case "not":
if(entity_filter(hass,value)(e))
return false;
break;
case "device":
if(!window.cardToolsData || !window.cardToolsData.devices)
return false;
let _deviceMatch = false;
for(const d of window.cardToolsData.devices) {
if (match(value, d.name)){
if(deviceEntities(d).includes(entity.entity_id))
_deviceMatch = true;
}
}
if(!_deviceMatch) return false;
break;
case "area":
if(!window.cardToolsData || !window.cardToolsData.areas)
return false;
let _areaMatch = false;
for (const a of window.cardToolsData.areas) {
if(match(value, a.name)) {
if(areaDevices(a).flatMap(deviceEntities).includes(entity.entity_id))
_areaMatch = true;
}
}
if(!_areaMatch) return false;
break;
default:
return false;
} }
} break;
return true;
case "not":
if(entity_filter(hass,value)(e))
return false;
break;
case "device":
if(!window.cardToolsData || !window.cardToolsData.devices)
return false;
let _deviceMatch = false;
for(const d of window.cardToolsData.devices) {
if (match(value, d.name)){
if(deviceEntities(d).includes(entity.entity_id))
_deviceMatch = true;
}
}
if(!_deviceMatch)
return false;
break;
case "area":
if(!window.cardToolsData || !window.cardToolsData.areas)
return false;
let _areaMatch = false;
for (const a of window.cardToolsData.areas) {
if(match(value, a.name)) {
if(areaDevices(a).flatMap(deviceEntities).includes(entity.entity_id))
_areaMatch = true;
}
}
if(!_areaMatch)
return false;
break;
default:
return false;
} }
} }
return true;
}
}