Here is the main script that I call once per day with an automation:
alias: choose_meal
sequence:
- if:
- condition: state
entity_id: counter.days_to_special_meal
state: "0"
then:
- service: input_text.set_value
data:
value: Special
target:
entity_id: input_text.type_of_meal_random
else:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.type_of_meal_filtered', 'options') |
length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.type_of_meal_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.type_of_meal_full',
'options')}})
target:
entity_id: input_select.type_of_meal_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.type_of_meal_filtered',
'options') | reject('in',
states('input_text.type_of_meal_random')) |list |random }}
target:
entity_id: input_text.type_of_meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.type_of_meal_filtered", "options")
if option != states("input_text.type_of_meal_random") %} {%
set ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id: input_select.type_of_meal_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.type_of_meal_filtered',
'options') | reject('in',
states('input_text.type_of_meal_random')) |list |random }}
target:
entity_id: input_text.type_of_meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.type_of_meal_full',
'options')}})
target:
entity_id: input_select.type_of_meal_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.type_of_meal_filtered', 'options') |
reject('in', states('input_text.type_of_meal_random')) |list
|random }}
target:
entity_id: input_text.type_of_meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.type_of_meal_filtered", "options") if
option != states("input_text.type_of_meal_random") %} {% set
ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id: input_select.type_of_meal_filtered
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_salad_filtered', 'options') | length
==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_salad_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: ({{ state_attr('input_select.meal_salad_full', 'options')}})
target:
entity_id:
- input_select.meal_salad_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_salad_filtered', 'options') |
reject('in', states('input_text.meal_salad_random')) |list
|random }}
target:
entity_id: input_text.meal_salad_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_salad_filtered", "options") if
option != states("input_text.meal_salad_random") %} {% set
ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id: input_select.meal_salad_filtered
enabled: true
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_salad_filtered', 'options') |
reject('in', states('input_text.meal_salad_random')) |list
|random }}
target:
entity_id: input_text.meal_salad_random
- service: input_select.set_options
data:
options: ({{ state_attr('input_select.meal_salad_full', 'options')}})
target:
entity_id:
- input_select.meal_salad_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_salad_filtered', 'options') |
reject('in', states('input_text.meal_salad_random')) |list |random
}}
target:
entity_id: input_text.meal_salad_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_salad_filtered", "options") if option
!= states("input_text.meal_salad_random") %} {% set ns.list =
ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id: input_select.meal_salad_filtered
enabled: true
- choose:
- conditions:
- condition: state
entity_id: input_text.type_of_meal_random
state: Special
sequence:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_special_filtered',
'options') | length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_special_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_special_full',
'options')}})
target:
entity_id:
- input_select.meal_special_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_special_filtered',
'options') | reject('in',
states('input_text.meal_random')) |list |random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_special_filtered",
"options") if option != states("input_text.meal_random")
%} {% set ns.list = ns.list+[option] %} {%endfor%}
{{ns.list}})
target:
entity_id:
- input_select.meal_special_filtered
- service: counter.reset
data: {}
target:
entity_id: counter.days_to_special_meal
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_special_filtered',
'options') | reject('in',
states('input_text.meal_random')) |list |random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_special_full',
'options')}})
target:
entity_id:
- input_select.meal_special_filtered
- service: counter.reset
data: {}
target:
entity_id: counter.days_to_special_meal
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_special_filtered',
'options') | reject('in', states('input_text.meal_random'))
|list |random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_special_filtered", "options")
if option != states("input_text.meal_random") %} {% set
ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_special_filtered
- service: counter.reset
data: {}
target:
entity_id: counter.days_to_special_meal
- conditions:
- condition: state
entity_id: input_text.type_of_meal_random
state: Pork
sequence:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_poark_filtered', 'options')
| length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_poark_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_pork_full',
'options')}})
target:
entity_id: input_select.meal_poark_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_poark_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_poark_filtered",
"options") if option != states("input_text.meal_random")
%} {% set ns.list = ns.list+[option] %} {%endfor%}
{{ns.list}})
target:
entity_id: input_select.meal_poark_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_poark_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_pork_full',
'options')}})
target:
entity_id: input_select.meal_poark_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_poark_filtered', 'options')
| random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_poark_filtered", "options") if
option != states("input_text.meal_random") %} {% set ns.list
= ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id: input_select.meal_poark_filtered
- service: counter.decrement
data: {}
target:
entity_id: counter.days_to_special_meal
enabled: true
- conditions:
- condition: state
entity_id: input_text.type_of_meal_random
state: Beef
sequence:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_beff_filtered', 'options') |
length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_beff_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_beff_full',
'options')}})
target:
entity_id: input_select.meal_beff_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_beff_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_beff_filtered", "options")
if option != states("input_text.meal_random") %} {% set
ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_beff_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_beff_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_beff_full',
'options')}})
target:
entity_id: input_select.meal_beff_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_beff_filtered', 'options')
| random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_beff_filtered", "options") if
option != states("input_text.meal_random") %} {% set ns.list
= ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_beff_filtered
- service: counter.decrement
data: {}
target:
entity_id: counter.days_to_special_meal
enabled: true
- conditions:
- condition: state
entity_id: input_text.type_of_meal_random
state: Vegan
sequence:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_vegan_filtered', 'options')
| length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_vegan_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_vegan_full',
'options')}})
target:
entity_id:
- input_select.meal_vegan_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_vegan_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_vegan_filtered",
"options") if option != states("input_text.meal_random")
%} {% set ns.list = ns.list+[option] %} {%endfor%}
{{ns.list}})
target:
entity_id:
- input_select.meal_vegan_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_vegan_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_vegan_full',
'options')}})
target:
entity_id:
- input_select.meal_vegan_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_vegan_filtered', 'options')
| random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_vegan_filtered", "options") if
option != states("input_text.meal_random") %} {% set ns.list
= ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_vegan_filtered
- service: counter.decrement
data: {}
target:
entity_id: counter.days_to_special_meal
enabled: true
- conditions:
- condition: state
entity_id: input_text.type_of_meal_random
state: Fish
sequence:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_fish_filtered', 'options') |
length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_fish_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_fish_full',
'options')}})
target:
entity_id:
- input_select.meal_fish_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_fish_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_fish_filtered", "options")
if option != states("input_text.meal_random") %} {% set
ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_fish_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_fish_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_fish_full',
'options')}})
target:
entity_id:
- input_select.meal_fish_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_fish_filtered', 'options')
| random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_fish_filtered", "options") if
option != states("input_text.meal_random") %} {% set ns.list
= ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_fish_filtered
- service: counter.decrement
data: {}
target:
entity_id: counter.days_to_special_meal
enabled: true
- conditions:
- condition: state
entity_id: input_text.type_of_meal_random
state: Eggs
sequence:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_eggs_filtered', 'options') |
length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_eggs_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_eggs_full',
'options')}})
target:
entity_id:
- input_select.meal_eggs_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_eggs_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_eggs_filtered", "options")
if option != states("input_text.meal_random") %} {% set
ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_eggs_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_eggs_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_eggs_full',
'options')}})
target:
entity_id:
- input_select.meal_eggs_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_eggs_filtered', 'options')
| random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_eggs_filtered", "options") if
option != states("input_text.meal_random") %} {% set ns.list
= ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_eggs_filtered
- service: counter.decrement
data: {}
target:
entity_id: counter.days_to_special_meal
enabled: true
- conditions:
- condition: state
entity_id: input_text.type_of_meal_random
state: Chicken
sequence:
- if:
- condition: template
value_template: >-
{{ state_attr('input_select.meal_chicken_filtered',
'options') | length ==1 }}
then:
- if:
- condition: state
entity_id: input_select.meal_chicken_filtered
state: RESET
then:
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_chicken_full',
'options')}})
target:
entity_id:
- input_select.meal_chicken_filtered
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_chicken_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_chicken_filtered",
"options") if option != states("input_text.meal_random")
%} {% set ns.list = ns.list+[option] %} {%endfor%}
{{ns.list}})
target:
entity_id:
- input_select.meal_chicken_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_chicken_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({{ state_attr('input_select.meal_chicken_full',
'options')}})
target:
entity_id:
- input_select.meal_chicken_filtered
else:
- service: input_text.set_value
data:
value: >-
{{ state_attr('input_select.meal_chicken_filtered',
'options') | random }}
target:
entity_id: input_text.meal_random
- service: input_select.set_options
data:
options: >-
({% set ns = namespace(list=[]) %} {% for option in
state_attr("input_select.meal_chicken_filtered", "options")
if option != states("input_text.meal_random") %} {% set
ns.list = ns.list+[option] %} {%endfor%} {{ns.list}})
target:
entity_id:
- input_select.meal_chicken_filtered
- service: counter.decrement
data: {}
target:
entity_id: counter.days_to_special_meal
enabled: true
default:
- service: notify.notify_marius
data:
title: Home Assistant
message: Error in chose food for the day.
mode: single
icon: mdi:food