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

Add device class support to MQTT cover #2092

Merged
merged 1 commit into from Jul 29, 2021

Conversation

krconv
Copy link
Contributor

@krconv krconv commented Jul 29, 2021

What does this implement/fix?

Adds device_class support in discovery for MQTT covers. Similar to #1832, which did the same thing for MQTT sensors.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes esphome/issues#2023 and fixes esphome/feature-requests#1158

Pull request in esphome-docs with documentation (if applicable): N/A

Test Environment

  • ESP32
  • ESP8266

Example entry for config.yaml:

mqtt:
  id: mqtt_client
  broker: !secret broker
  username: !secret mqtt_username
  password: !secret mqtt_password

switch:
  - platform: gpio
    pin: D3
    name: "Garage Door Open Switch"
    id: open_switch
  - platform: gpio
    pin: D4
    name: "Garage Door Close Switch"
    id: close_switch

cover:
  - platform: template
    device_class: garage
    name: "Garage Door"
    open_action:
      - switch.turn_off: close_switch
      - switch.turn_on: open_switch
      - delay: 0.1s
      - switch.turn_off: open_switch
    close_action:
      - switch.turn_off: open_switch
      - switch.turn_on: close_switch
      - delay: 0.1s
      - switch.turn_off: close_switch
    stop_action:
      - switch.turn_off: close_switch
      - switch.turn_off: open_switch
    optimistic: true
    assumed_state: true

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@krconv
Copy link
Contributor Author

krconv commented Jul 29, 2021

I checked through the rest of the MQTT components, and I think covers + sensors are the only ones with device_class

Copy link
Member

@OttoWinter OttoWinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

ESPHome Dev automation moved this from Needs Review to Reviewer Approved Jul 29, 2021
@OttoWinter OttoWinter merged commit de382b7 into esphome:dev Jul 29, 2021
ESPHome Dev automation moved this from Reviewer Approved to Done Jul 29, 2021
This was referenced Aug 11, 2021
@krconv krconv deleted the add-device-class-to-mqtt-cover branch August 19, 2021 11:15
@github-actions github-actions bot locked and limited conversation to collaborators Sep 14, 2021
ESPHome Dev automation moved this from Done to Reviewer Approved Sep 23, 2023
ESPHome Dev automation moved this from Reviewer Approved to Done Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging this pull request may close these issues.

Device class attribute is missing in MQTT discovery payload Publish device_class via MQTT Autodiscovery
2 participants