Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there way I could replace Z Wave tilt sensor on garage door instead of using magnetic sensors? #27

Open
slonkar opened this issue Oct 9, 2018 · 4 comments

Comments

@slonkar
Copy link

slonkar commented Oct 9, 2018

I already have Z wave sensor mounted on my garage door. If I am not wrong, you are using magnetic sensors to basically broadcast the state of the door. Is there way I could tweak your code in-order to support Z Wave + relay configuration instead of magnetic switch + relay configuration?

@walthowd
Copy link

walthowd commented Oct 9, 2018

Assuming you are using Home Assistant?

I use Z wave sensors and just have the cover set to optimistic and it works fine.

- platform: mqtt
  name: "Garage Door North"
  state_topic: "garage/door/north/status"
  command_topic: "garage/door/north/action"
  availability_topic: "GarHAge/availability"
  optimistic: true
  qos: 0
  retain: false
  payload_open: "OPEN"
  payload_close: "CLOSE"
  payload_stop: "STATE"
  state_open: "open"
  state_closed: "closed"
  payload_available: "online"
  payload_not_available: "offline"

Then I have a template switch that I use to mainly control the door, that reports the status via the Z wave sensor:

- platform: template
  switches:
    garage_door_north:
      value_template: "{{ is_state('sensor.garage_door_north_tilt_alarm_level', '255') }}"
      turn_on:
        service: cover.open_cover
        data:
          entity_id: cover.garage_door_north
      turn_off:
        service: cover.close_cover
        data:
          entity_id: cover.garage_door_north
      icon_template: >-
        {% if is_state('sensor.garage_door_north_tilt_alarm_level', '255') %}
          mdi:garage-open
        {% else %}
          mdi:garage
        {% endif %}

Finally, I also have some Node-RED flows that read the state of the sensors and inject the MQTT messages to keep the state topics on the garage door cover in sync. Not needed in my setup, but just to have everything reporting the same across the board.

@marthoc
Copy link
Owner

marthoc commented Oct 16, 2018

@slonkar - you can use the template cover component of HA to do this. Essentially what @walthowd showed you except instead of a switch you get a cover device at the end. Useful if you’re using the HomeKit component so that it shows as a Garage Door, for instance. Let me know if you need better instructions...

@marthoc
Copy link
Owner

marthoc commented Oct 16, 2018

@walthowd you could do this more simply like so:

- platform: template
  covers:
    garage_door:
      friendly_name: "Garage Door"
      value_template: {{ is_state('binary_sensor.garage_door', 'open') }}
      open_cover:
        service: mqtt.publish
        data:
          topic: garage/door/1/action
          payload: OPEN
      close_cover:
        service: mqtt.publish
        data:
          topic: garage/door/1/action
          payload: CLOSE

And then in customize.yaml:

cover.garage_door:
  device_class: garage

Which will give you the changing icons and make sure it shows up properly in HomeKit.

This approach saves you having to make a dummy cover and set optimistic etc. Passing the mqtt topic and payload through a template cover is much cleaner I think.

@shoeman22
Copy link

shoeman22 commented Dec 16, 2018

Just wanted to comment and say that this cover approach worked perfect for me using an Ecolink
Z-Wave Plus Tilt Sensor
.

Based on how I did my binary sensors, I had to check for "on" instead of "open". Here's the relevant config for me. binary_sensor.main_bay_garage_door_tilt_binary_sensor is created automatically by the tilt sensor when HA brings it it. I could probably just use it but I like making explicitly binary_sensors in case I ever need to muck with the logic in the future, I won't have to change my references elsewhere.

Here's my final config for reference (note I also changed in config.h the mqtt topic)

binary_sensor:
  - platform: template
    sensors:
      is_main_bay_garage_door_open:
        value_template: '{% if is_state("binary_sensor.main_bay_garage_door_tilt_binary_sensor", "off") %}false{% else %}true{% endif %}'
        device_class: garage_door
        friendly_name: 'Main Bay Garage Door (tilt)'
        entity_id: binary_sensor.main_bay_garage_door_tilt_binary_sensor

cover:
  - platform: template
    covers:
      main_bay_garage_door:
        friendly_name: "Main Bay Garage Door"
        value_template: "{{ is_state('binary_sensor.is_main_bay_garage_door_open', 'on') }}"
        entity_id: binary_sensor.is_main_bay_garage_door_open
        open_cover:
          service: mqtt.publish
          data:
            topic: garage/main_bay/action
            payload: OPEN
        close_cover:
          service: mqtt.publish
          data:
            topic: garage/main_bay/action
            payload: CLOSE

Also, thank you very much @marthoc for garHAge in general. This is the first time I've ever really mucked around with DIY on a circuit board project like this and your instructions and bill of materials were absolutely top notch. A very rewarding home automation afternoon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants