Show/Hide Entity Status (Text) in HAFloorplan based on another entity status condition #264
Replies: 4 comments 11 replies
-
Yes I think you are trying to do what I asked about here #156 There will be a couple of ways to achieve this. I use the following to hide a power value when it is low (I.e. off)
What you can also do is have the text always shown as the value of sensor.entity1 and then have a polygon over the top of it that is hidden in one state of entity.sensor2 and shown in the other. The polygon would be the same colour as your background so it “hides” the value when it is in view. Hopefully that makes sense. |
Beta Was this translation helpful? Give feedback.
-
☕ Did you find this useful, and would you like to say thanks? Buy me a coffee at: https://www.buymeacoffee.com/coffeetoexetico (Support my ha-floorplan work, say thanks for 1-to-1 help in discussions and whatever else you think about 😺) My suggestion is this one, but try the other cases, if you have the time to do so ;-) The functions: |
>
return {
controlEntity1And2FunctionSimple: (
entities, entityKey1, entityKey2
) => {
try {
const entity1 = entities[entityKey1];
const entity2 = entities[entityKey2];
let textValue = false;
if(entity2.state === "on"){
textValue = Math.round(entity1.state * 10) / 10 + "°";
}
return textValue ? textValue : '';
} catch (e) {
console.log("Something failed on the way...", e);
return 'Error';
}
}, And the following code should be used for elements involved, in the - service: floorplan.text_set
service_data:
element: "sensor.hallway"
text: |
> /* Use this function for both entities, to secure updates on both */
const textValue = functions.controlEntity1And2FunctionSimple(entities, "sensor.aqara_sensor2_temperature", "light.spotlys_gang")
return textValue; If you have one rule with both the entities, you can save some duplication by combining it into this: name: Case 4
entities:
- sensor.aqara_sensor2_temperature
- light.spotlys_gang
element: area.hallway
tap_action:
service: light.toggle
service_data:
entity_id: light.spotlys_gang
state_action:
- service: floorplan.class_set
service_data:
class: '${(entity.state === "on") ? "light-on" : "light-off"}'
- service: floorplan.dataset_set
service_data: 'light:${entity.state}'
- service: floorplan.text_set
service_data:
element: "sensor.hallway"
text: |
> /* Use this function for both entities, to secure updates on both */
const textValue = functions.controlEntity1And2FunctionSimple(entities, "sensor.aqara_sensor2_temperature", "light.spotlys_gang")
return textValue; The logics from the functions can also be moved into the same I hope you find some of the suggestions useful. |
Beta Was this translation helpful? Give feedback.
-
@exetico Thanks for all the detail in this response which shows all the flexibility available. You've described in here the use of startup_action and variables. I'm trying to find them in the Usage guide, but don't see them there or in the Lovelace page linked from the actions section of the Usage. Can you point me at where they are described? |
Beta Was this translation helpful? Give feedback.
-
Excellent, I'll look through those. |
Beta Was this translation helpful? Give feedback.
-
Good morning,
this is my goal: I would like to show and hide a text (the numeric status of an entity (for simplicity I'll call it entity1) - I've already managed to display it in HAfloorplan without condition) based on a condition, more precisely on a status, of another entity (for convenience entity2).
Here is what I wrote:
Thank You very much in advance
Beta Was this translation helpful? Give feedback.
All reactions