How to remotely read/delete/write YAML file via coding?

Hi all,

I would like to implement add/edit/delete YAML file remotely.

I noted that SambaShare add ons could add/edit/delete YAML file folder in local network using local IP.

But you can’t access this folder outside the network.

My aim is to remotely access read this YAML file (Example: light.yaml), then delete the all content of this file, and re-writes all contents in the format I want. But this need to achieve via coding way.

So how could I do achieve this via coding?

Thanks.

I think you can place on GitHub and just update file there and sync same to HA server.

Reboot needed after changes.
This can be manual or programmed

1 Like

If you are using HassIO then there are two different add ons that can do this. Configurator gives you basically a web page add on. And there is Visual Studio Code which is what it is called.

1 Like

Cool, but I am looking for a solution that does not requires code to remote repository GitHub

I knew that HassIO can support both Configurator and Visual Studio Code, but I wanna a solution that could bypass login credential can edit this YAML file if possible.

You would still need some method of telling Hass to restart and read the changed configuration. I am having trouble seeing the usefulness in what you wish other than just saying you can do it.

Why bypass login credentials?

You could use ssh with an authorized_keys / private key and use nano to edit…

1 Like

Especially remotely! Locally you could use the trusted networks authentication provider.

1 Like

You could probably use Syncthing. Have a read

1 Like

I am fine with editing YAML file via VSCode/SSH/etc.

But the problem is my family member don’t have any programming/networking knowledge at all. So impossible for them using VSCode/SSH/etc.

So I thought of design a simple UI or etc so that they can edit it remote easily. By doing so, definitely need to have some way to bypass credentials.

Maybe I make things more complicated in this case.

After reading this, I curious how VSCode/Cloud 9 IDE could expose these files for remote edits via specific port?

What kind of methology is used in this case?

So I am curious, if your end users/family members don’t have programming knowledge what are they changing?
In theory you only need to set up the yaml file once and never need to change it.

Of course my family members no need to change device ID, MQTT, etc. As this is to done by myself.

What they need is just to change the entity name such as light name/fan name and timer duration such as 5 seconds (If required to change).

Others are not required at all.

That’s why I an thinking of a method to achieve this.

They can add friendly names using the web UI. This is currently broken in 0.91 though.

1 Like

Why? At least entity IDs should always remain the same. Otherwise automations that reference them would break. And could you give an example where it makes sense to rename the friendly name only? As long as a device serves the same purpose (e.g. kitchen light), why should it be renamed?

Search around the forum. People have come up with entities (UI elements) where you can set durations for timers.

My general thought on this: only people who really know what they are doing should get access to the configuration. You’d be pretty upset if someone changes an automation you rely on without you knowing about it.

2 Likes

That’s what I suspected. As others have indicated this can be changed in the web front end and there is no need to adjust the yaml files.

2 Likes

If this is the case, I would just remain myself to edit all these configurations.

Thanks for the support!

Noted and thanks.