Hi All
I’m new in home asssistant arround two month a go. I have tried to look for information about what I want but have not found it.
I have the following picture-element and I have a custom:button-card and what I want to do is that when the sun is below_horizon the button doesn’t appear and when the sun is above_horizon comes up.
The code I have is this
type: picture-elements
image: /local/floorplan/01_PlantaBaja/01_PlantaBaja_Noche.png
elements:
- type: image
entity: sun.sun
state_image:
below_horizon: /local/floorplan/01_PlantaBaja/01_PlantaBaja_Noche.png
above_horizon: /local/floorplan/01_PlantaBaja/01_PlantaBaja_Dia.png
style:
top: 50%
left: 50%
width: 100%
- type: custom:button-card
icon: mdi:lightbulb
show_name: false
entity: switch.pruebas_mss310_main_channel
aspect_ratio: 3/1
styles:
card:
- border-radius: 40%
- box-shadow: 0px 0px 3px 3px green
- height: 45px
- width: 45pX
- margin-top: 0px 5px 0px 0px
icon:
- margin-top: '-5%'
style:
top: 56%
left: 17%
width: 3%
tap_action:
action: toggle
state:
- value: 'on'
styles:
card:
- box-shadow: 0px 0px 3px 3px red
icon: null
icon: mdi:lightbulb-on
color: red
I have tried the following to add inside de card the next code
- display: |
[[[
if ( states['sun.sun'].state == 'above_horizon' )
return 'none'
return 'block'
]]]
other optios I tried
- display: >-
[[[
return (states['sun.sun'].state == 'above_horizon') ? 'none' : 'block';
]]]
I get the following error
52 | - margin-top: 0px 5px 0px 0px
53 | - display: >
54 | [[[
55 | return (states['sun.sun'].state == 'above_hor ...
---------------------------------^
56 | ? 'none' : 'none'
57 | ]]]
Could you tell me the best way to solve the problem or could you tell me where I can find some information about this?
Many thanks in advance
Regards