Virtual Entities (value or string) can auto update based on a Global variables?
-
Hi, I tried with my skills and no luck, so I want understand if it is possible.
if I create a Global variable, for example to have a Thom Index value
xB1_Thom_Index_ID = round( float( xB1_Temp_01_ID ) - (0.55-0.0055 * float( xB1_Humidity_01_ID )) * ( float( xB1_Temp_01_ID ) - 14.5) , 1)
and then I create a Virtual Entity that show the updated value also on the dashboard every time xB1_Thom_Index_ID changes
seems that this is not the right way
id: testA_dynamic_vec name: TestA Dynamic Vec Value capabilities: value_sensor: attributes: value: expr: xB1_Thom_Index_ID
nothing
id: testA_dynamic_vec name: TestA Dynamic Vec Value capabilities: value_sensor: attributes: value: expr: round( float( xB1_Temp_01_ID ) - (0.55-0.0055 * float( xB1_Humidity_01_ID )) * ( float( xB1_Temp_01_ID ) - 14.5) , 1)
I get the value updated only when MSR restart. Is this way totally wrong?
Thanks in advance
-
Hi, I tried with my skills and no luck, so I want understand if it is possible.
if I create a Global variable, for example to have a Thom Index value
xB1_Thom_Index_ID = round( float( xB1_Temp_01_ID ) - (0.55-0.0055 * float( xB1_Humidity_01_ID )) * ( float( xB1_Temp_01_ID ) - 14.5) , 1)
and then I create a Virtual Entity that show the updated value also on the dashboard every time xB1_Thom_Index_ID changes
seems that this is not the right way
id: testA_dynamic_vec name: TestA Dynamic Vec Value capabilities: value_sensor: attributes: value: expr: xB1_Thom_Index_ID
nothing
id: testA_dynamic_vec name: TestA Dynamic Vec Value capabilities: value_sensor: attributes: value: expr: round( float( xB1_Temp_01_ID ) - (0.55-0.0055 * float( xB1_Humidity_01_ID )) * ( float( xB1_Temp_01_ID ) - 14.5) , 1)
I get the value updated only when MSR restart. Is this way totally wrong?
Thanks in advance
@noelab said in Virtual Entities (value or string) can auto update based on a Global variables?:
seems that this is not the right way
That actually is the right way. You may have found a bug. I'd like to see the rest of the expressions involved, though. I need to see all of the global variables mentioned in your expression (and any they mention).
-
@noelab said in Virtual Entities (value or string) can auto update based on a Global variables?:
seems that this is not the right way
That actually is the right way. You may have found a bug. I'd like to see the rest of the expressions involved, though. I need to see all of the global variables mentioned in your expression (and any they mention).
Reactor (Multi-hub) latest-23338-170ea0c7
Docker - Synology NASGlobal expression
xB1_Temp_01_ID = getEntity( "ezlo>device_626d5f9f129e2912444634a4" ).attributes.temperature_sensor.value
xB1_Humidity_01_ID = getEntity( "ezlo>device_626d5f9f129e2912444634a0" ).attributes.humidity_sensor.value
in reactor.yaml
- id: testA_dynamic_vec name: TestA Dynamic Vec Value capabilities: value_sensor: attributes: value: expr: round( float( xB1_Temp_01_ID ) - (0.55-0.0055 * float( xB1_Humidity_01_ID )) * ( float( xB1_Temp_01_ID ) - 14.5) , 1)
in dashboard
-
or
glabal expression
xB1_IndiceThom_ID = round( float( xB1_Temp_01_ID ) - (0.55-0.0055 * float( xB1_Humidity_01_ID )) * ( float( xB1_Temp_01_ID ) - 14.5) , 1)
reactor.yaml
- id: testA_dynamic_vec name: TestA Dynamic Vec Value capabilities: value_sensor: attributes: value: expr: xB1_IndiceThom_ID
-
Great. Thank you. Two things going on here. One you can fix, one I have to fix.
First, you have to help the dashboard figure out how to display your entity. For that, you need to make two additional entries in your config for your virtual entity. Add the two lines I show at the end here:
id: testA_dynamic_vec name: TestA Dynamic Vec Value capabilities: value_sensor: attributes: value: expr: xB1_Thom_Index_ID primary_attribute: value_sensor.value type: ValueSensor
Setting
primary_attribute
helps the dashboard figure out which attribute to display. Thetype
determines the widget type, which can be:Switch
— an on/off switch;Light
— a dimmable light or multi-level switch;Valve
— a water valve;Lock
— a door lock;BinarySensor
— a binary sensor;SecuritySensor
— a security sensor (special case of binary sensor for door, window, glass break, etc.);Button
— a pushbutton (entity must havebutton
capability);Script
— a script (like a Vera scene, Hass automation or script, etc.);MediaPlayer
— a media player (hasmedia_player
and other related capabilities);Camera
— a camera;Weather
— weather entity (implementswx
capability);Cover
— window covering, garage door, etc.
Now, that said, there is indeed a bug in handling attribute changes. It appears VirtualEntityController is aware the variable has changed, but it's consistently getting the previous value rather than the new value for the expression, and I know what's causing that. It will take a couple of days for me to fix and get out a new build.
-
Can you tell me what your Reactor install is? Docker? What architecture?
These things are supposed to be in your original post, per the posting guidelines. Please re-read the posting guidelines for this category so that your future posts contain the information requested for every post.
-
T toggledbits locked this topic on