Closed ando023 closed 4 years ago
Figured an alternate way to achieve this. Closing the issue now, hopefully this might help someone in the future.
In home assistant there is TimeOfDay(TOD) binary sensors that can be created.
To achieve a Day/ Night cycle I added the following to my configuration.yaml
:
binary_sensor:
- platform: tod
name: Night_Sensor
after: sunset
before: sunrise
- platform: tod
name: Day_Sensor
after: sunrise
before: sunset
After a restart of home assistant, you should now see two new binary sensors called;
Validate that each sensor displays the correct on
or off
function. If you have your day and night sensors showing as on
or off
you have configured your binary sensor wrong. Check the code and validate it again.
If you have done it correctly, you should have something like this;
In the card that you want to apply this too, copy the following;
- type: conditional
conditions:
- entity: binary_sensor.night_sensor
state: 'on'
card:
type: 'custom:simple-weather-card'
name: 'Night Forcast:'
entity: sensor.wupws_weather_1n
backdrop:
day: '#f6ca69'
night: '#568bd9'
- type: conditional
conditions:
- entity: binary_sensor.day_sensor
state: 'on'
card:
type: 'custom:simple-weather-card'
name: 'Night Forcast:'
entity: sensor.wupws_weather_1d
backdrop:
day: '#568bd9'
night: '#f6ca69'
Based from the on
or off
status of either binary_sensor.night_sensor
or binary_sensor.day_sensor
enables the day or night versions of the forecast cards.
As an example this is how I have my weather card setup for the day/ night cycles:
Nice solution, thanks for sharing, consider checking out iantrich/config-template-card as well, could come in handy for situations like this.
I have two sensors showing the day and night weather forecasts which work fine. However to see each forecast I have to have two cards setup.
Would it be possible to add additional options in custom options to allow for time of day sensors?
Say something like this for example?