I am building a media player integration for my SFR stb in visual studio code.
in my config folder there is a file with my sources:
sources.json
'{"TF1": "1", "France 2": "2","France 3": "3"...}'
how to define a file in media_player.py with the sources.json content ?
source_list = '{"TF1": "1", "France 2": "2","France 3": "3"...}'
I made a little progress
I found how to access my file
for example in the setup_platform function this works:
from homeassistant.util.json import load_json
...
config_path = hass.config.path("sources.json")
source_list = load_json(config_path)
but not return a string (it’s normal)
How to make source_list a string
I tried
with open(config_path) as f:
source_list = f.readlines()
Reports a error
config_path = hass.config.path("sources.json")
with open(config_path, encoding="utf8") as f:
source_list = f.read()
![:slight_smile: :slight_smile:](https://community.home-assistant.io/images/emoji/twitter/slight_smile.png?v=10)