I know not many of you use Mochad to control old X10 devices but I was hoping you might be able to give me a suggestion on how to test if Mochad isn’t running properly. Unfortunately this is happening more frequently for some reason that I don’t understand.
When I look at my dashboard, I see that the devices are unavailable.
The first thing I tried was to create an automation to test if Mochad is running.
- id: '1696112398023'
alias: Restart Mochad if not running
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.mochad_running
from: 'on'
to: 'off'
- platform: state
entity_id:
- binary_sensor.mochad_running
from: 'on'
to: unavailable
condition: []
action:
- service: hassio.addon_stop
data:
addon: 185c312f_mochad
- delay:
hours: 0
minutes: 0
seconds: 15
milliseconds: 0
- service: hassio.addon_start
data:
addon: 185c312f_mochad
mode: single
But that didn’t work because Mochad still thinks it’s running:
Then I created an automation to check if three switches were unavailable. If so, I stop and restart Mochad.
- id: '1694801523246'
alias: Mochad availability
description: Check every 15 minutes if X10 devices are available
trigger:
- platform: time_pattern
minutes: /15
condition: []
action:
- if:
- condition: state
entity_id: switch.living_room_led_left
state: unavailable
- condition: and
conditions:
- condition: state
entity_id: light.master_ceiling_light
state: unavailable
- condition: and
conditions:
- condition: state
entity_id: switch.media_tv_lights
state: unavailable
then:
- service: hassio.addon_stop
data:
addon: 185c312f_mochad
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- service: hassio.addon_start
data:
addon: 185c312f_mochad
mode: single
But that automation fails because it can’t find the entities.
So I need some help. What else can I test for?
The addon thinks it is running (green dot) when I look at the addon screen but isn’t using any CPU or RAM.
Any suggestions would be greatly appreciated!
I think this might work. We’ll see as soon as Mochad goes south again. I created a template and it says “on” so I’m keeping my fingers crossed.Thanks for the idea @WallyR
{{ states('switch.living_room_led_left') is defined }}
The Mochad integration built into HA, and the Mochad server add-on are two separate programs and either one could be screwing up. I don’t normally run HA on a Pi, but I loaded HA on a Pi3b(1GB ram) and Mochad add-on shows 0% CPU and 0.5% RAM when it is working fine. My guess is that the Mochad server add-on is working, and it is the Mochad integration built into HA that is screwing up for you.
When it screws up, you can access the Mochad server add-on from another computer to see if it is working. For testing, I use PuTTY from ( http://putty.org) and telnet to the Mochad server using its IP address and port 1099. All the x10 activity shows up in the PuTTY output, and you can control lights by entering PL A10 ON or PL A10 OFF, where A10 is the house code and unit number.
Yes @jazzyisj that is showing false and I have not restarted Mochad to rectify the problem so this looks like it might be the trigger I need to fix this problem. I’ll put this test in and send a text to myself when it’s triggered. Will let you know.
That condition will prevent the automation from running and causing an error but it won’t tell you something is wrong (unless you do an if/then/else using that condition in the action and do a notification in there somehow and even then it won’t be until the automation is triggered.)
You can create a template sensor that can be used to notify you as soon as your entities go unknown or unavailable. You can limit it to just monitor the integration you’re having a problem with.
If your integration is acting up regularly and restarting the addon is the fix, you can also automate restarting the addon instead of starting and stopping it.