home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.89k stars 30.97k forks source link

Cover template - Device_class not working #40636

Closed Bredin76 closed 4 years ago

Bredin76 commented 4 years ago

The problem

I'm unable to make device_class work in cover template. First - i tried to create a cover with device class garage thru ESPHome => it is known in HA as a standard shutter Then - I tried to create the same cover with device class directly thru HA in my cover.yaml ( where there is all my covers. It's not an ESPHome file) => same issue so i think the problem is HA side ( or user side) but not specifically ESPHome side

Environment

image

I have never tried to do that before this 0.115.3 release

Problem-relevant configuration.yaml

  - platform: template
    covers:
        porte_du_garage:
            friendly_name: "porte du garage"
            device_class: garage
            value_template: "{{ is_state('binary_sensor.garage_door_contact_sensor','off') }}"
            open_cover:
              service: switch.turn_on
              data:
                entity_id: switch.garage_door_relay
            stop_cover:
              service: switch.turn_on
              data:
                entity_id: switch.garage_door_relay
            close_cover:
              service: switch.turn_on
              data:
                entity_id: switch.garage_door_relay

i also post the yaml of my ESPHome config... nevermind...

substitutions:
  friendly_name: Porte Garage

esphome:
  name: porte
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret ssid
  password: !secret ssid_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "THE Fallback Hotspot"
    password: "THE PASSWORD"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: !secret api_password

ota:
  password: !secret api_password
  id : my_ota
  # Le 24 V n'est pas comme dans la notice de la porte. Il est sur le PP Gauche et le Stop Droit
  # il est nécessaire d'uploader fichier .yaml (le firmware) quand on crée les switch et autres. Pour ca, passer par le addon ESPHOME 
# The door contact sensor that is attached to SW on the 
# Shelly 1. Not exposed to HA, instead used to set the 
# state of the cover.
binary_sensor:
  - platform: gpio
    pin: GPIO5
    name: "Garage Door Contact Sensor"
    id: contact_sensor
    filters:
      - invert:

# The relay in the Shelly 1 that will deliver the pulse to
# the garage door opener (not exposed to HA)
switch:
  - platform: gpio
    pin: GPIO4
    name: "Garage Door Relay"
    id: relay

# This creates the actual garage door in HA. The state is based
# on the contact sensor. Opening/closing the garage door simply
# turns the relay on/off with a 0.5s delay in between.
cover:
  - platform: template
    device_class: garage
    name: "Garage Door"
    id: template_cov
    lambda: |-
      if (id(contact_sensor).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      - switch.turn_on: relay
      - delay: 0.5s
      - switch.turn_off: relay
    close_action:
      - switch.turn_on: relay
      - delay: 0.5s
      - switch.turn_off: relay

Traceback/Error logs

return in lovelace : image

No specific log 

Additional information

Bredin76 commented 4 years ago

Damn... i forgot a customize_domain...

homeassistant:
   customize_domain: #for all covers 
      cover:
      device_class: shutter