Modules - how to reference the cards entity? #1786
Answered
by
Clooos
DJF3
asked this question in
Questions about config, custom styles and templates
-
GoalDynamically change the state color and font-weight through a module Source YamlModule:
${card.querySelector('.bubble-state').style.color =
hass.states['binary_sensor.door_3attic_left_contact'].state === 'on' ? 'red' : 'lime'}
${card.querySelector('.bubble-state').style.fontWeight =
hass.states['binary_sensor.door_3attic_left_contact'].state === 'on' ? 'bold' : 'normal'}
.bubble-sub-buttonWhich step did you already try?All kinds of versions, including this one:
${card.querySelector('.bubble-state').style.color =
hass.states[entity.entity_id].state === 'on' ? 'red' : 'lime'}
${card.querySelector('.bubble-state').style.fontWeight =
hass.states[entity.entity_id].state === 'on' ? 'bold' : 'normal'}
Also checked the code used in this module:
https://github.com/Clooos/Bubble-Card/discussions/1446ProblemNot sure if/how I can reference the card entity_id from within the module, followed by getting the entity state and do something based on that state. Read the documentation
|
Beta Was this translation helpful? Give feedback.
Answered by
Clooos
Aug 25, 2025
Replies: 1 comment 2 replies
-
|
Hi! You can just use All variables are explained here: |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
DJF3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! You can just use
stateinstead ofhass.states['binary_sensor.door_3attic_left_contact'].state, this will use the card's entity 🙂All variables are explained here:
https://github.com/Clooos/Bubble-Card/?tab=readme-ov-file#available-variables-and-functions