Closed hAMMERlized closed 1 year ago
Hi @hAMMERlized, that's an excellent request. The current card allows you to choose between a climate.entity_id or a temperature sensor.entity_id but doesn't provide an option to combine them.
To address this, let's add this feature by replacing lines 188-211 in the climate.yaml
template with the following code:
label: |
[[[
if (!variables.entity) {
return "Label";
}
if (variables.label) {
return variables.label;
}
let temperature;
const entityState = states[variables.entity];
const temperatureOverriderState = states[variables.temperature_overrider];
if (temperatureOverriderState && temperatureOverriderState.state) {
temperature = temperatureOverriderState.state;
} else if (entityState.attributes.current_temperature) {
temperature = entityState.attributes.current_temperature;
} else if (entityState.attributes.device_class === 'temperature') {
temperature = entityState.state;
}
if (!temperature) {
return 'Unavailable';
}
const unit = variables.temp_unit || 'celsius';
const unitSymbol = unit === 'fahrenheit' ? '°F' : '°C';
return parseFloat(temperature).toFixed(1) + ' ' + unitSymbol;
]]]
Then add the new variable temperature_overrider
in the 3.1_air_heating.yaml
view like this
- type: custom:button-card # ENTITY 01
template: climate
variables:
entity: climate.entity_id
temperature_overrider: sensor.entity_id
name:
This should fulfill your requirement. I want to let you know that I'm working on a major version 2.0.0 update QLM dashboard. It will include support for a dark mode and bring other enhancements that will need you to reconfigure your files, especially the views, but you can still practice with your current 1.0 version to understand how it works.
Please let me know if this code is functioning correctly and feel free to reach out for further improvements.
Sorry for the late response! Thanks for the code, it works perfectly!
Good to hear that you are still working under the hood. Keep up the good work. I love your code and i have already tweaked and changed the style here and there :)
For further improvement i'll open a new issue if it's okay for you. Just for better overview. You can delete / rename or whatever it if you like to.
Hey @neilimixamo ,
this is not an issue, more a request / a question but I don't know how to post or declare it otherwise.
As I am not that familiar with template coding I would like you to ask what would the code look like and where exactly to replace it in the climate.yaml to state the indoor temperature from a temperature sensor of my choices instead from the sensor from the air-conditioner unit. Because the state from the units sensor is always too high or too low.
I would appreciate it if you could help me out with that. Thanks. Love your code so far!