Where is moshad integration?

I’m running HA in a container on an Rpi4. It works with the MQTT integration though mosquitto is running on the host. I have moshad running, also not in container, and I can send commands in the terminal, such as echo ‘pl a2 on’ | nc localhost 1099 . I put this in the config yaml:

mochad:
  host: localhost
  port: 1099

switch:
  - platform: mochad
    devices:
      - address: a2
        name: ceiling_lights
        comm_type: pl
      - address: a3
        name: ceiling_fan
        comm_type: pl

What else do I need to issue moshad commands through HA? Are there custom components? Thanks.

I don’t know what you mean my moshad commands (by which I assume you mean mochad commands).

The integration says it supports light and switch. Do you get light and switch entities?

1 Like

I do not see any entries for mochad (not moshad, sorry) in the entities list, or for ceiling_lights or ceiling_fan. That’s why I think I’m missing something. But when I click add integration and search for mochad, I find nothing. What do I need to install or add besides the configuration.yaml entries to get mochad entities. Thanks.

You won’t find it there because it is not configured via UI.

So no switch.whatever?

What do your logs show?

Logbook shows nothing because there’s no entity related to mochad or to the switches in the dropdown on the logbook page. Is it really that all that HA needs are the entries in config.yaml? On the HA docs page referring to mochad there is a link to “mochad component,” but that link only refers back to the same page. There needn’t be any files in custom_components for mochad, as there are for say, govee? Thanks again for help.

no because it is not a custom component.

The mochad component is set up by these lines:

mochad:
  host:
  port:

You say you are running ha in docker, what --network did you set in your docker commandline?

I said log not logbook.

grep mochad home-assistant.log

If nothing then

Bump the logging up for mochad, see Logger - Home Assistant

I used --network=host \

That is correct.

I get these errors: from home-assistant.log:

~/homeassistant/.config $ grep mochad home-assistant.log
2022-06-08 17:40:34 ERROR (MainThread) [homeassistant.components.switch] Error while setting up mochad platform for switch
  File "/usr/src/homeassistant/homeassistant/components/mochad/switch.py", line 45, in setup_platform
    add_entities([MochadSwitch(hass, mochad_controller.ctrl, dev) for dev in devs])
  File "/usr/src/homeassistant/homeassistant/components/mochad/switch.py", line 45, in <listcomp>
    add_entities([MochadSwitch(hass, mochad_controller.ctrl, dev) for dev in devs])
  File "/usr/src/homeassistant/homeassistant/components/mochad/switch.py", line 62, in __init__
  File "/usr/src/homeassistant/homeassistant/components/mochad/switch.py", line 106, in _get_device_status
  File "/usr/local/lib/python3.9/site-packages/pymochad/device.py", line 55, in get_status
  File "/usr/local/lib/python3.9/site-packages/pymochad/controller.py", line 83, in read_data

Does this help?

It might help. Is the mochad daemon running on the PC running home assistant?

it’s an Rpi4 and yes, systemctl status mochad shows it active. It is running on the host, not in a container.

I found one error in the config yaml and changed comm_type from pl to rf. Now I have the entities ceiling_lights and ceiling_fan. When I use this in an automation and run the action, the trace says it has executed:

Executed: June 8, 2022, 6:56:24 PM
Result:
params:
  domain: switch
  service: turn_on
  service_data: {}
  target:
    entity_id:
      - switch.ceiling_lights
running_script: false
limit: 10

But the lights don’t turn on. When I run this command in a terminal window:

echo 'rf a2 on' | nc localhost 1099

the lights do turn on. I am using version 0.1.21 mochad from

 https://sourceforge.net/projects/mochad/

Does HA expect a different version of mochad or use a different command to send to nc? Thanks again.

At least we are getting somewhere!

HA does not use nc. It uses pymochad.

I have to go out of town tomorrow but will work on that Friday. Do you know of an installation link or will I need to build pymochad from source?

pymochad is a dependency of the HA mochad integration, and your installation should have included it. Which method did you install HA by?

I used this docker command:

 docker run -d -p 12101:12101 \
      --name rhasspy \
      --restart unless-stopped \
      -v "$HOME/.config/rhasspy/profiles:/profiles" \
      -v "/etc/localtime:/etc/localtime:ro" \
      --device /dev/snd:/dev/snd \
      rhasspy/rhasspy \
      --user-profiles /profiles \
      --profile en

That’s rhasspy not ha, but you installed via docker I guess.

Sorry. pasted wrong lines as I was hurrying to get going. This was HA docker run:

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=America/Denver \
  -v /home/voice/homeassistant/.config/:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

The pymochad docs https://pymochad.readthedocs.io/en/latest/readme.html link to the nc daemon, so it is still needed.

pymochad is included in the the ha image.

Yes, As I said in the first post I am trying to get mochad to work when HA is running in a docker container. I can’t use the disk image as there is no way that I know of to use the matrix voice with the diskimage. (If anyone knows a way, I’d love to hear it.)
So, HA in docker. HA uses pymochad, which is a library of python scripts that call the TCP daemon nc. From the terminal, nc is running and sends signals to the physical devices. In HA, running an automation with the switch does nothing, even though trace says the action was run. So I went looking for pymochad within the docker container holding HA. There is a folder in there called custom_components that has folders for hacs, govee (both of which work) and for mochad. That folder, unlike the others, is empty. Could this be the problem? The other custom_components folders have .py and .json files. Should the mochad folder have these files, and if so, where can I get them?