DrozmotiX / ioBroker.esphome

Control your ESP8266/ESP32 with simple yet powerful configuration files created and managed by ESPHome
MIT License
30 stars 23 forks source link

Fan component not working #205

Open tukey42 opened 5 months ago

tukey42 commented 5 months ago

!!! Before you start !!!

Describe the bug
When using a fan component in ESPHome, the adapter just creates one readonly state in ioBroker instead of multiple states (e.g. speed, direction, ...). See the log below.

In the adapter code I see the following call:

case 'Fan':
    await this.handleRegularState(`${host}`, entity, state, false);
    break;

I don't know, if the call should be replaced by a call to async handleStateArrays(host, entity, state)

To Reproduce
Steps to reproduce the behavior:

  1. Create a new device with given yaml.
  2. compile and flash the device
  3. see the states in ioBroker

Minimal! Yaml config to reproduce.
Keep all that is required to copy-paste, compile, flash and reproduce the issue - but try to remove as much as possible that is not relevant to this issue!
Just an example, insert you own yaml!:

esphome:
  name: test
  friendly_name: Test

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "verysecretapipassword"

ota:
  password: "verysecretotapassword"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:

web_server:
  port: 80   

captive_portal:

output:
  - platform: esp8266_pwm
    id: motor_forward_pin
    pin: GPIO12
#    name: forward
  - platform: esp8266_pwm
    id: motor_reverse_pin
    pin: GPIO13
#    name: backward

fan:
  - platform: hbridge
    id: my_fan
    name: "Living Room Fan"
    pin_a: motor_forward_pin
    pin_b: motor_reverse_pin
    # enable_pin: motor_enable
    decay_mode: slow   # slow decay mode (coasting) or fast decay (braking).

Expected behavior
At least three states (state, direction, speed), which can control the fan, should be created in ioBroker

Logs (as screenshot and in text-form)

Create_state called for : 18FE34D64BD8.Fan.774144226.state with value : false
[entityStateData] {"key":774144226,"state":false,"oscillating":false,"speed":0,"direction":0,"speedLevel":54}
[entityStateConfig] {"config":{"objectId":"living_room_fan","key":774144226,"name":"Living Room Fan","uniqueId":"testfanliving_room_fan","supportsOscillation":false,"supportsSpeed":true,"supportsDirection":true,"supportedSpeedLevels":100,"disabledByDefault":false,"icon":"","entityCategory":0},"name":"Living Room Fan","type":"Fan","unit":""}

Versions: