I use a Roku Express media player as my internet tv server. I have a simple UI on my dashboard to choose a source (eg BBC iPlayer) and a channel (eg BBC News). I have a json data array that provides the commands to be sent to the Roku Express for each source/channel combination. It all works very well except I have a maintenance issue. I set value_json from a long text string in three separate places in the code.
I would like to use the file platform to load the json array as an attribute of a sensor. The json array is stored in the config folder. As a first step, I have tried:
in sensors.yaml but a sensor is not created. Is the file_path correct? Development Tools tells me the value of value_json.sources[0].name is ‘BBC iPlayer’. Any and all help gratefully received.
Well you definitely have an indentation issue because that’s not valid YAML. Your sensor would work if put into your configuration.yaml file like this:
Sounds like you’ve extracted some of the YAML in configuration.yaml file to a separate sensors.yaml file that is !included somehow. Feel free to adjust accordingly based on how you did that.
I’m confused why you have this JSON duplicated all over though. Wouldn’t it be easier to just make a template select? Set the list of options in its config and have it send the correct command in select option based on the selected option. Then just use that select entity everywhere in your automations and UI.