For even more fun here is another MQTT (yay for no polling!) example with a vehicle state entity and distance entity. This requires a version of the firmware that reports the distance to the /OUT/DIST MQTT topic.
- 80 is my door threshold
- 150 is my vehicle threshold
- a compatible firmware can be found here (thanks @gabe565)
- platform: template
sensors:
garage_door_status:
friendly_name: 'Garage Door Status'
value_template: '{{states.cover.garage_door.state}}'
garage_vehicle_state:
friendly_name: "Vehicle State"
value_template: >-
{% if states.sensor.opengarage_distance.state | int == 0 %}
Disabled
{% elif (states.sensor.opengarage_distance.state | int > 0) and (states.sensor.opengarage_distance.state | int <= 80) %}
Unknown (Door Open)
{% elif (states.sensor.opengarage_distance.state | int > 80) and (states.sensor.opengarage_distance.state | int <= 150) %}
Present
{% else %}
Absent
{% endif %}
- platform: mqtt
name: "OpenGarage Distance"
state_topic: "OpenGarage/OUT/DIST"
unit_of_measurement: "cm"
cover:
- platform: mqtt
name: "Garage Door"
command_topic: "OpenGarage/IN/STATE"
state_topic: "OpenGarage/OUT/STATE"
state_open: "OPEN"
state_closed: "CLOSED"
payload_open: "open"
payload_close: "close"
device_class: "garage"
Then groups.yaml can have this or whatever:
garage:
name: Garage Door
entities:
- cover.garage_door
- sensor.garage_door_status
- sensor.garage_vehicle_state
- sensor.opengarage_distance