Update: [Solved] with some bells & whistles
edit: Small change to account for multiple non-zero values.
Here are code snippets I made for a simple Syncthing On / Off status indicator:
In a binary_sensor.yaml file add the following:
- platform: command_line
command: ssh [user@IP of Syncthing] "if ps ax | grep -v grep | grep syncthing > /tmp/test.txt; then echo 1; else echo 0; fi"
If you don’t need to ssh into your Syncthing then it’s just:
command: if ps ax | grep -v grep | grep syncthing > /tmp/test.txt; then echo 1; else echo 0; fi
You can then make the sensor displayable via a groups.yaml, e.g
And of course have the includes in your configuration.yaml as needed:
group: !include groups.yaml
binary_sensor: !include binary_sensor.yaml
The section on my Hass page:
Hope it’s useful for someone. Of course the fun, by no means, ends there!
One feature of Home Assistant allows you to make a sensor out of the value of a text file, say ‘hallway-lights.txt’ and the text file contains the word ‘off’ or ‘on’. Make the sensor trigger on a change in that value, and change the lights accordingly.
So simply make a folder in the Home Assistant server with such a text file, have Syncthing installed and link it to your phone Syncthing.
Now all you have to do is change the value of the text file on your phone, and no matter where in the world you are, Home Assistant will change the light at home. I’ve had turn-around times of 5 seconds to 90 seconds.
That’s of course a simple example, everything you can connect to Home Assistant can be controlled via such simple text files and more sophisticated customisable config files. Which yet again can be amended via Syncthing.
The upshot of all this? One major privacy / security headache caused by the Intenet of Things can be neutered by Syncthing. By being the secure transport / encryption layer for all the functions of Home Assistant - a total personal oversight of the whole loop can be accomplished.
I combine this with a DNS server at home (e.g. Pi-hole.net) to silence the frighteningly chatty IoT devices I have and leave them only capable of talking locally. Home Assistant also lets you dispense with many of the mini-hubs the devices ‘need’ so that’s handy too.
Manually editing text files is of course clumsy, but it’s my proof-of-concept stage.
I’m off to give Android Studio a go and make a simple app that will do the ‘On / Off’ etc in a more elegant manner. If anyone knows of a pre-made template like that, please let me know!
So many thanks Syncthing, and Home Assistant (and Pi-Hole) - I think you’ve won the Internet of Things Software Stack Award 2016!!!