Any feedback/help please?
There must be something stupid I am doing that stop all the rest of the static text to be showed.
Any feedback/help please?
There must be something stupid I am doing that stop all the rest of the static text to be showed.
Did you try states['binary_sensor.andrea_oneplus5_charging'].state === true ? 'Charging' : 'Not Charging'
?
Yes, by itself it does work (and yes, I changed true to on)
If it is working by itself, the template should be fine. With variables
now possible, I would try putting in variables
.
Current status:
secondary_info: "${'OnePlus 5 Battery: ' + states['sensor.andrea_oneplus5_battery'].state + '%' + states['binary_sensor.andrea_oneplus5_charging'].state === 'on' ? ' - Charging' : ''}"
Result in:
While this:
secondary_info: "${states['binary_sensor.andrea_oneplus5_charging'].state === 'on' ? 'Charging' : ''}"
Correctly return:
You mean put the text in a variable?
What if you just try secondary_info: "${states['binary_sensor.andrea_oneplus5_charging'].state === 'on' ? 'Charging' : 'Not Charging'}"
?
Ehm, itâs my second example, which works correctly
Here is a other example i wanted to do that since a while, make the opacity of the lights on my 3D floor plan follow my real lights. thanks for that card!!!
Here is a little video demonstration:
https://youtu.be/qj2n5xoRNT0
- type: 'custom:config-template-card'
config:
type: 'custom:card-modder'
card:
type: 'custom:hui-picture-elements-card'
image: /local/floorplan.png
elements:
- entity: light.kitchen
image: /local/fp_kitchen_off.png
style:
left: 66.9%
top: 26.7%
width: 17.88%
state_filter:
'off': opacity(0%)
'on': >-
${"opacity(" + (states['light.kitchen'].attributes.brightness /
2.55) + "%)"}
tap_action:
action: toggle
type: image
Awesome!
Iâm going to plan on adding updates only on attribute changes in the future as well which should improve performance for anyone using attributes
EDIT: Wait, Iâm already checking the full state object for the entityâŚnevermind Just restricting by entities
will work
Try this
secondary_info: "${'OnePlus 5 Battery: ' + states['sensor.andrea_oneplus5_battery'].state + '%' + (states['binary_sensor.andrea_oneplus5_charging'].state === 'on' ? ' - Charging' : '')}"
I believe the eval didnât like your ternary not being wrapped. I tested it here and is probably a good place to test your logic quickly:
Hi @iantrich, I tried your code but it actually returns a new error:
I also tried to check the JS Bin site you posted but I am not sure how am I supposed to use it because also when I add the code you suggested it return an error
"SyntaxError: Invalid or unexpected token
Share you new config
You canât just copy that line into jsbin, if you see what I defined for states, it doesnât match yourâs exactly. You also need to not include the ${}
as I strip those out in my code before running eval
Oh I am sorry!
I didnât realize that the link was pointing to a pre-coded page, I tought the code was just example and I pasted the code in there , my bad!
Regarding the YAML error in HA I added an unnecessary additonal white space at the beginning, now it works!!!
Thank you so much!
Looking great, care to share your config of the card?
Sure thing, here it is:
- type: custom:config-template-card
config:
type: custom:hui-entities-card
title: House Members
show_header_toggle: false
entities:
- entity: person.andrea
type: "custom:secondaryinfo-entity-row"
secondary_info: "${'OnePlus 5 Battery: ' + states['sensor.andrea_oneplus5_battery'].state + '%' + (states['binary_sensor.andrea_oneplus5_charging'].state === 'on' ? ' - Charging' : '')}"
I tried variables:
card:
type: 'custom:hui-entities-card'
title: MQTT & Wifi Connections
show_header_toggle: false
variables:
- states['sensor.sonoff1_2914_status'].attributes['MqttCount']
- states['sensor.sonoff1_2914_status'].attributes['WiFi LinkCount']
entities:
- entity: sensor.sonoff1_2914_status
name: "${'Coffee' + '\xa0'.repeat(16) + 'MQTT ' + vars[0] + '\xa0'.repeat(4) + 'WiFi ' + vars[1]}"
But it shows unknown⌠did I do something wrong?
Also trying this:
- entity: sensor.sonoff1_2914_status
name: "${'Coffee' + '\xa0'.repeat(16) + 'MQTT ' + states['sensor.sonoff1_2914_status'].attributes['MqttCount'] + '\xa0'.repeat(4) + 'WiFi ' + states['sensor.sonoff1_2914_status'].attributes['WiFi LinkCount'] + states['sensor.sonoff1_2914_status'] >= 100 ? 'Excellent' : states['sensor.sonoff1_2914_status'] > 80 ? 'Good' : states['sensor.sonoff1_2914_status'] > 60 ? 'Fair' : 'Weak'}"
To append information about the WiFi RSSI strength⌠Excellent, Good, Fair or Weak to the end⌠but doesnât seem to like that either
Any ideas?
I got my variables: option before the config:/card: line of custom:config-template-card.
Ah that will be it for the error⌠but why isnât my conditional info showing?
- entity: sensor.sonoff1_2914_status
name: "${'Coffee' + '\xa0'.repeat(16) + 'MQTT ' + states['sensor.sonoff1_2914_status'].attributes['MqttCount'] + '\xa0'.repeat(4) + 'WiFi ' + states['sensor.sonoff1_2914_status'].attributes['WiFi LinkCount'] + states['sensor.sonoff1_2914_status'] >= 100 ? 'Excellent' : states['sensor.sonoff1_2914_status'] > 80 ? 'Good' : states['sensor.sonoff1_2914_status'] > 60 ? 'Fair' : 'Weak'}"
states[âsensor.sonoff1_2914_statusâ] probably is not giving you a number, maybe parseFloat(states[âsensor.sonoff1_2914_statusâ].state) ?