Remove entities tap_action patch
This commit is contained in:
parent
5ab9c62cd8
commit
97018c7d67
39
README.md
39
README.md
@ -246,45 +246,6 @@ card:
|
|||||||
```
|
```
|
||||||

|

|
||||||
|
|
||||||
# Bonus function - entities card tap\_action
|
|
||||||
With card-mod installed, you will be able to use `tap_action` with rows in your entities cards:
|
|
||||||
|
|
||||||
Example:
|
|
||||||
```yaml
|
|
||||||
type: entities
|
|
||||||
entities:
|
|
||||||
- entity: light.bed_light
|
|
||||||
name: default
|
|
||||||
- entity: light.bed_light
|
|
||||||
name: toggle
|
|
||||||
tap_action:
|
|
||||||
action: toggle
|
|
||||||
- entity: light.bed_light
|
|
||||||
name: navigate
|
|
||||||
tap_action:
|
|
||||||
action: navigate
|
|
||||||
navigation_path: /lovelace/1
|
|
||||||
- entity: light.bed_light
|
|
||||||
name: url
|
|
||||||
tap_action:
|
|
||||||
action: url
|
|
||||||
url_path: https://google.com
|
|
||||||
- entity: light.bed_light
|
|
||||||
name: call-service
|
|
||||||
tap_action:
|
|
||||||
action: call-service
|
|
||||||
service: browser_mod.popup
|
|
||||||
service_data:
|
|
||||||
deviceID: this
|
|
||||||
title: Popup
|
|
||||||
card:
|
|
||||||
type: entities
|
|
||||||
entities:
|
|
||||||
- light.bed_light
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# FAQ
|
# FAQ
|
||||||
|
|
||||||
### How do I convert my old card-modder configuration to card-mod?
|
### How do I convert my old card-modder configuration to card-mod?
|
||||||
|
@ -28,40 +28,5 @@ customElements.whenDefined('hui-entities-card').then(() => {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntitiesCard.prototype._handleClick = function(config) {
|
|
||||||
const action = config.tap_action && config.tap_action.action ? config.tap_action.action : "more-info";
|
|
||||||
switch(action) {
|
|
||||||
case "more-info":
|
|
||||||
fireEvent("hass-more-info", { entityId: config.entity }, this);
|
|
||||||
break;
|
|
||||||
case "navigate":
|
|
||||||
history.pushState(null, "", config.tap_action.navigation_path);
|
|
||||||
fireEvent("location-changed", {}, this);
|
|
||||||
break;
|
|
||||||
case "url":
|
|
||||||
if(config.tap_action.url_path) {
|
|
||||||
window.open(config.tap_action.url_path);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "toggle":
|
|
||||||
if(config.entity) {
|
|
||||||
const domain = config.entity.split(".", 1)[0];
|
|
||||||
const isOff = ["closed", "locked", "off"].includes(this._hass.states[config.entity].state)
|
|
||||||
const service = ({
|
|
||||||
lock: ["unlock", "lock"],
|
|
||||||
cover: ["open_cover", "close_cover"]}[domain]
|
|
||||||
|| ["turn_on", "turn_off"])[isOff?0:1];
|
|
||||||
this._hass.callService(domain, service, { entity_id: config.entity });
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "call-service": {
|
|
||||||
if(!config.tap_action.service) break;
|
|
||||||
const [domain, service] = config.tap_action.service.split(".", 2);
|
|
||||||
this._hass.callService(domain, service, config.tap_action.service_data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fireEvent('ll-rebuild', {});
|
fireEvent('ll-rebuild', {});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user