Getting started on custom device

Hi,

I’m creating a doorbell using some raspberry pi zero’s. I trying to get started with home assist but I find it hard to get the right info. I’m at the point where I can make the raspberry subscribe to a switch using mqtt and act accordingly, but I’m looking for something custom.

  • There is one raspberry sensing a motion and then publishing its state (on/off) to some topic.
  • There are multiple clients (raspberry with speaker that can play a sound) that should subscribe to this topic and read the state (on/off).
  • Additionally I want per client a mute button and a volume button. There should also be a mute button to mute all clients simulteneously.

So I’m not asking for somebody to write me code, I’m asking if someone could translate this story into some steps that I have to take so I can read the appropriate documentation.

Add a MQTT binary sensor if you want to know whether there’s motion or not.

MQTT switch and MQTT number

Put your MQTT switches in a group.

Thanks a lot, I got the sensor working and also the volume. I’m having trouble with the automation. If I force it, it does the job, however it doesn’t trigger on the binary sensor state. Where am I making the mistake?

switch:
  - platform: mqtt
    unique_id: bell_client_1
    name: "bell_client_1"
    state_topic: "house/bell/ring"
    command_topic: "house/bell/ring/set"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true

binary_sensor:
  - platform: mqtt
    name: "Motion Sensor Gate 1"
    unique_id: motion_gate_1
    state_topic: "house/motion/motion_gate_1"
    payload_on: "ON"
    payload_off: "OFF"
    availability:
      - topic: "house/motion/motion_gate_1/availability"
        payload_available: "online"
        payload_not_available: "offline"
    qos: 0
    device_class: motion
    value_template: "{{ value_json.state }}"

automation:
  - alias: "Ring bell on"
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_gate_1
        to: "on"
    action:
      - service: switch.turn_on
        target:
          entity_id: switch.bell_client_1
  - alias: "Ring bell off"
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_gate_1
        to: "off"
    action:
      - service: switch.turn_off
        target:
          entity_id: switch.bell_client_1

I don’t see a reason why your automation shouldn’t work.
Please check the history graph to see if the sensor changed state.
You could also use developer tools to see what its current state is.
Open your Home Assistant instance and show your state developer tools.
Maybe the on state only lasts for a very short time. I guess you could add for: "00:00:02" to your off trigger to make it last longer.

Thank you, great tool! I made a typo in the sensor name, which is why it didn’t trigger. Thanks a lot for your help, it works now.