Open Akshue opened 3 years ago
Only some things are written down to YAML by Home Assistant when you use the UI, e.g. automations, but devices are always stored as something called "config entries" in the internal database (stored under .storage
). The internal database is for Home Assistant only and not something you should mess with manually. You will have to add configuration to configuration.yaml
yourself.
If you are familiar with shell commands, and ssh in your HA system, you can do:
import sys, yaml, json
data=json.loads(sys.stdin.read()) entries = data['data']['entries'] output = [] for element in entries: if 'domain' in element and element['domain'] == 'localtuya': element['data'].pop('product_key', None) output.append(element['data'])
print(yaml.dump({ "localtuya": output }, sort_keys=False))
- Then find your `core.config_entries` in your `.storage` directory, then execute the command bellow by replacing <file_path> by the directory where your `.storage` directory is located:
```sh
cat <file_path>/.storage/core.config_entries | python3 convert.py
It should produce a yaml
configuration of the already configured devices through config_flow
that you can put in your configuration.yaml
.
What is running ha? Intel nuc? Raspberry pi? theres something you can install within ha supervisor called file editor(used to be call configurator)
for a raspberry pi the file is inside config folder. You can also setup a smb connection to the ha instance.
Figured it out. Also, I made something that I figured I'd share.
In case you are adding a ton of lights/switches... (I had over 200) I put them into an excel spreadsheet by pulling out keys/ip's/ID's/and typing in friendly names. I also made addition columns for the different selections. Then, feel free to use this code to generate things that you can copy/paste into the file editor in HA.
lights:
=" - host: "&C4&CHAR(10)&" device_id: "&D4&CHAR(10)&" local_key: "&B4&CHAR(10)&" friendly_name: "&A4&CHAR(10)&" protocol_version: "&CHAR(34)&3.3&CHAR(34)&CHAR(10)&" entities:"&CHAR(10)&" - platform: light"&CHAR(10)& " friendly_name: "&A4&CHAR(10)&" id: "&G4&" "&CHAR(10)&" color_mode: "&H4&" "&CHAR(10)&" brightness: "&I4&" "&CHAR(10)&" color_temp: "&J4&" "&CHAR(10)&" color: "&K4&" "&CHAR(10)&" brightness_lower: "&L4&" "&CHAR(10)&" brightness_upper: "&M4&" "&CHAR(10)&" color_temp_min_kelvin: 2700 "&CHAR(10)&" color_temp_max_kelvin: 6500 "&CHAR(10)&" scene: "&N4&" "&CHAR(10)&" music_mode: False "&CHAR(10)
On/Off switches
=" - host: "&C10&CHAR(10)&" device_id: "&D10&CHAR(10)&" local_key: "&B10&CHAR(10)&" friendly_name: "&A10&CHAR(10)&" protocol_version: "&CHAR(34)&3.3&CHAR(34)&CHAR(10)&" entities:"&CHAR(10)&" - platform: switch"&CHAR(10)& " friendly_name: "&A10&CHAR(10)&" id: "&G10&" "&CHAR(10)
Columns A- Friendly Name B - Key C - IP D - ID G - Entity ID (1/20) H - 2/21 I - 3/22 J - 4/25 K - 5/24 L - Min Brightness (25/29) M - Max Brightness (255/1000) N - 6/25
All my lights had the same white color range.
Sorry, newbie question.
I have added a few devices with the wizard, and things are going well so far. I have about 230 devices to go.
That being said - I'd rather do this via text editor. However, I can't seem to find the configuration data. The configurations.yaml in the config folder is still "new", and does not show what I already added. The localtuya directory is all python files, no configuration that I can find.
Where is the data that I added? How can I do this via text?