This is part of a much larger project of mine, so while I’m aware there are more proper ways of doing this, I want to see if anyone knows how to do this specific thing.
I want to create an input_text via a package in configuration.yaml (I’m using the include_dir_merge_named method of creating packages). I want to make the input_text using a jinja dict, primarily because my ultimate goal is to create a list of input_text’s based on the contents of a group in home assistant.
This is the correct way to create an input_text in the config file
bulb_setting_default:
input_text:
default1:
max: 255
initial: 'hi'
I’m trying to accomplish the most basic piece here, so instead of doing the above configuration I want to do the configuration using a jinja dict like I have here:
bulb_setting_default:
input_text: |
{% set testval = {"default1": {"max": 255, "initial": 'hi'}} %}
{{ testval }}
When I try to use this config and reload my yaml in the dev tools, I get an error:
Setup of package 'bulb_setting_default' failed: Invalid package definition 'bulb_setting_default': expected dict for dictionary value @ data['input_text']. Package will not be initialized
This is not unexpected, however I still feel this is possible because I’m doing something hacky in my automations where I set the data of a light using json from a text_helper like so:
service: light.turn_on
continue_on_error: true
metadata: {}
data: |
{{states('input_text.default_bedtime_color') | from_json}}
target:
area_id:
- upstairs_hallway
- living_room
entity_id:
- light.children_s_bedtime_lights_off
The content of input_text.default_bedtime_color is this:
{"rgb_color":[255,0,0],"brightness_pct":50}
So my problem is that it works in an automation, but not in a config file. If I can get this working it will make my blueprint significantly smaller. If anyone knows a way to create helpers dynamically please let me know, thanks!