have a sensor with possible values 1 (low tariff) or 2 (high)
want to have the icon change depending accordingly, and the color. Color template works fine, icon won’t change.
Anyone spot the error? More-info does show the correct mdi icon…?
having tried all possible options documented and seen on the community… (at least, as far as my eyes could spot the differences, I just figured, why not…
took out the _template of icon_template, and what do you know:
sure, it is a customization of my sensor.huidig_tarief, which is directly taken from the smart meter (which is connected over Modbus to my Mqtt enabled Z-wave hub…)
homeassistant:
customize:
sensor.huidig_tarief:
templates:
icon: >
if (state === '1') return 'mdi:numeric-1-box-multiple-outline';
if (state === '2') return 'mdi:numeric-2-box-multiple-outline';
return 'mdi:fire';
theme: >
if (state === '1') return 'green';
return 'orange';
_stateDisplay: >
if (state === '1') return 'Laag';
return 'Hoog';
if you don’t have that, you can always make an automation based on the time the Laag-tarief starts and ends. Might be even simpler
feel free to adapt this Boiler-switch automation…
- alias: Boiler switch
id: 'Boiler switch'
trigger:
- platform: state
entity_id: sensor.huidig_tarief
# - platform: state
# entity_id: sensor.zp_actuele_opbrengst
- platform: state
entity_id: binary_sensor.zp_opbrengst_threshold_input
condition:
- condition: template
value_template: >
{{ trigger.to_state.state is not none and
trigger.from_state.state is not none and
trigger.to_state.state != trigger.from_state.state }}
# - condition: template
# value_template: >
# {{ states('binary_sensor.zp_opbrengst_threshold_input') in ['on','off'] }}
- condition: template
value_template: >
{{ (as_timestamp(now()) -
as_timestamp(state_attr('automation.boiler_switch','last_triggered'))
| default(0) | int > 240) }}
- condition: template
value_template: >
{{ states('switch.sw_boiler_bijkeuken_template') !=
('on' if is_state('binary_sensor.zp_opbrengst_threshold_input','on') or
is_state('sensor.huidig_tarief', '1')
else 'off')}}
action:
- service_template: >
switch.turn_{{'on' if is_state('binary_sensor.zp_opbrengst_threshold_input','on') or
is_state('sensor.huidig_tarief', '1') else 'off'}}
entity_id: switch.sw_boiler_bijkeuken_template
- condition: template
value_template: >
{{ is_state('input_boolean.notify_system', 'on')}}
- service: notify.notify
data_template:
message: >
Threshold: {{states('binary_sensor.zp_opbrengst_threshold_input')}}, ZP {{states('sensor.zp_actuele_opbrengst')}}, Tarief {{states('sensor.huidig_tarief')}}:
Switching Boiler: {{'on' if is_state('binary_sensor.zp_opbrengst_threshold_input','on') or
is_state('sensor.huidig_tarief', '1') else 'off' }}.
kicks in when Tarief is Laag, or Solar Production is more than a threshold, in this case set by an input_number used by the binary_sensor. Switches off again when either of the triggers do (enter Hoog tarief or solarprocduction less than threshold)
What I want to craete at the end is an automation to work with all of de heating devices in my system, but to activate under different surcumstanses.
ie
heatpipes = always
heatpump = weekdays hoog tarief turn on at lower than 40 C turn of at 50 C, low tarief turn on below 50 C turn of at 55
heatingrod = only turn on in laag tarief with a temp below 40 C
heatpump = in the night from sat to sun heat to 60C starting at 21:00, when still nog 60 C at ie 2:00, turn on heatrod as well (legionella prevention 1x a week)
Well all is possible I guess, but I like it to do automated as much as possible. No use needing to flip the switch manually if the sensors.switches allow for automation.
That is not really what I menth. a sensor that gives a 0 or 1 or true or false or on or off falleu depending on laag or hoog tarief to use in other automations
to be able to use different settings for laag or hoog tarief