Trying to send last valid values from a sensor to a MQTT topic in order to set new sensors, as the original sensors (ESPHome) get unavailable state from time to time:
automation:
- alias: flora_2_remove_unavailable_values
initial_state: true
trigger:
- platform: state
entity_id: sensor.flora_air_temperature_2
- platform: state
entity_id: sensor.flora_light_intensity_2
- platform: state
entity_id: sensor.flora_soil_fertility_2
- platform: state
entity_id: sensor.flora_soil_moisture_2
condition:
condition: template
value_template: >-
{{ trigger.to_state.state not in ['unavailable', trigger.from_state.state] }}
action:
service: mqtt.publish
data_template:
topic: "flora/{{ trigger.entity_id.split('.')[1].split('_')[2] }}"
payload: "{{ trigger.to_state.state }}"
the automation, although fires (last_triggered is updated each time the original sensors get modified values, so the trigger works), it doesn’t publish anything (and there isn’t any error in the log).
In templates {{ states.sensor.flora_soil_fertility_2.entity_id.split(".")[1].split('_')[2] }} correctly gets fertility, thus the action should work too.
The original sensor updates several time per minute (when not sending unavailable state) and the values are almost always different than previous.
It seems that the automation was correct and worked in the initial form, but I haven’t restarted HA since last week and I made some frontend changes during the weekend (after which a restart was probably necessary).
I see you have that sun position custom component. Very nice. I’d really like to add it but it is still not compatible with home assistant (core / hassio).
I just need to find a better place for the plants and for me to have a beer
It is an input select with the names of Chromecast audios/groups and then a script reading weather:
read_weather:
alias: 'Weather forecast'
sequence:
- service: tts.google_translate_say
data_template:
entity_id: '{{ states.input_select.weather_read_media_player.state}}'
message: >
{{["Hello.","Good morning.","Greetings.","Hi."] | random}} It's currently {{states.sensor.dark_sky_summary.state}} and {{states.sensor.dark_sky_temperature.state|round}} degrees. Today will be {{states.sensor.dark_sky_hourly_summary.state|replace(".", "")}}, highs: {{states.weather.dark_sky.attributes.forecast[0].temperature|round}}, lows: {{states.weather.dark_sky.attributes.forecast[0].templow|round}} Maximum precipitation intensity: {{states.sensor.dark_sky_precip_intensity.state | round(2)}} mm.
I will update those too with button cards (just completed in the weekend recreating quite a lot of scenes with the MiLight bulbs similar to Hue Scenes and I will overhaul some other parts of the frontend) but I currently struggle mighty with the horizontal alignment of cards as some of them are conditional and constantly varying in vertical size. Just hope that HA version 0.108 will improve things.