I’m using the flic component (https://home-assistant.io/components/binary_sensor.flic/) that communicates with the flicd (https://github.com/50ButtonsEach/fliclib-linux-hci) service. Sometimes the flicd just stops. I’ve got automation set up that checks the process (system monitor) and me sends a notification after which I start flicd by hand. I will look into restarting this as part of an automation (shell command) later. But the issue I want to tackle first…
The home assistant flic component only detects the flic buttons if the flicd was started first. After manually starting up flicd, I’m currently restarting home assistant completely, but that seems like overkill.
Is it possible to just restart the flicd component or reset it somehow?
I’m having the exact same issue. I can restart the service without issue but restarting home assistant is not fun each time you have to restart flicd service
I was thinking to watch the log file for the flic error and then set an automation to restart service / wait / restart home assistant…
Problem is that I put the button on my wife’s night table to control lights/fan/good morning/good night so I’m taking a bit of heat each time the button fails!
I was thinking about the problem today and I have come up with something clunky that should work
here is a python script which reads the home-assistant.log for “binary_sensor.flic” - returns true or false
# coding: utf8
word = "value_json.processes.flic"
result = "false"
with open('/home/homeassistant/.homeassistant/home-assistant.log') as file:
data = file.read()
if word in data:
result = "true"
this is the sensor config in yaml
- platform: command_line
command: "python /home/homeassistant/.homeassistant/python_scripts/flic.py"
Then a shell command to restart the flic service ( my flic is on a remote pi so I have to SSH in )
flic_restart: 'ssh [email protected] sudo systemctl restart flicd'
now we can create an automation to put it together
- alias: flic_restart
- platform: state
- service: shell_command.flic_restart
- delay: 00:00:10
- service: script.restart_ha
Clunky as heck and I may see some times where home assistant is unavailable while rebooting.
It might be cleaner to have the OS system take care of the daemon restart. I don’t know if that would obviate the need to restart ha or not, but would be worth a try. It looks like you are using systemctl to start your flicd daemon so just add
Restart=always in the Service section. That should monitor the daemon and restart it if it crashes.
A few things have happened since I started this topic
- I’ve swapped the power supply of my PI with the original power supply (PI/HA stopped crashing)
- I’ve configured the flicd service to run as an actual service (like @zarthan said, check this)
- Upgraded to latest HA releases every time
The result is a PI that has been running for over 8 days without HA halting. Although I haven’t been home for a few days and have not used the flic buttons, there has not been an interruption since the last reboot. Flicd seems to have been running without issues.
However, I still have the original question: is it possible to restart a single platform or component. I haven’t seen anything that points in that direction after looking at the source code. The flic component could maybe be refactored to be somewhat fault tolerant and reconnect to the flicd server.
Also, I believe the flic component in HA might not be able to handle a restart of the flicd service, as per my original problem. I did configure the flicd service to restart automatically though.