lucavb / homebridge-esphome-ts

This plugin integrates your esphome devices into HomeKit!
GNU General Public License v3.0
47 stars 16 forks source link

Fan support #150

Open rithask opened 3 years ago

rithask commented 3 years ago

Can you add fan support so that it'll show as a fan in Apple Home app. Thanks.

lucavb commented 2 years ago

Okay so good news, I don't see any reason why we should not be able to make this happen. I just need to figure out how the fans are behaving in esphome. And maybe I will need you as a tester. I'll update you when I am ready.

rithask commented 2 years ago

Sure, that's great.

rithask commented 2 years ago

Any updates on this?

lucavb commented 2 years ago

Alright, can you try installing version 1.6.0-beta.0? Ideally it should automatically pick up the fan.

rithask commented 2 years ago

The first command from homebridge-esphome-ts after a while gets executed instatly. But the next commands after it takes a few seconds.

The logs from ESPHome:

[21:37:54][D][api:095]: Accepted 192.168.1.2
[21:37:54][V][api.connection:711]: Hello from client: 'esphome-ts (192.168.1.2)'
[21:37:54][D][api.connection:727]: esphome-ts (192.168.1.2): Connected successfully
[21:37:56][D][api:095]: Accepted 192.168.1.2
[21:37:56][V][api.connection:711]: Hello from client: 'Home Assistant 2021.8.8 (192.168.1.2)'
[21:37:56][D][api.connection:727]: Home Assistant 2021.8.8 (192.168.1.2): Connected successfully
[21:38:03]pm open,type:0 0
[21:38:24][D][remote_transmitter:066]: Sending remote code...
[21:38:24][V][component:207]: Component api took a long time for an operation (0.12 s).
[21:38:24][V][component:208]: Components should block for at most 20-30ms.
[21:38:24][D][speed.fan:035]: Setting speed: 0.67
[21:38:24][D][speed.fan:046]: Setting oscillation: OFF
[21:38:54][D][remote_transmitter:066]: Sending remote code...
[21:38:54][D][remote_transmitter:066]: Sending remote code...
[21:38:54][V][component:207]: Component api took a long time for an operation (0.24 s).
[21:38:54][V][component:208]: Components should block for at most 20-30ms.
[21:38:54][D][speed.fan:035]: Setting speed: 0.00
[21:38:54][D][speed.fan:046]: Setting oscillation: OFF
[21:39:24][D][remote_transmitter:066]: Sending remote code...
[21:39:24][D][remote_transmitter:066]: Sending remote code...
[21:39:24][V][component:207]: Component api took a long time for an operation (0.24 s).
[21:39:24][V][component:208]: Components should block for at most 20-30ms.
[21:39:24][D][speed.fan:035]: Setting speed: 0.67
[21:39:24][D][speed.fan:046]: Setting oscillation: OFF
lucavb commented 2 years ago

Would you be so kind and start this with the debug option mentioned in the README? Ideally with controlling the fan as well. Maybe this will tell us something.

https://github.com/lucavb/homebridge-esphome-ts#troubleshooting

rithask commented 2 years ago

Are you looking for this? There's nothing besides this in the Homebridge logs.

[10/25/2021, 3:02:01 PM] [esphome] rfan discovered and setup.
[10/25/2021, 3:02:01 PM] [esphome] {
  rfan: FanComponent {
    listEntity: {
      objectId: 'rfan',
      key: 1908344392,
      name: 'rfan',
      uniqueId: 'rfannativefanrfan',
      supportsOscillation: true,
      supportsSpeed: true,
      supportsDirection: false
    },
    commandInterface: EspSocket {
      host: 'rfannative.local',
      port: 6053,
      data: [Subject],
      connected: [BehaviorSubject],
      timeout: [Subject],
      error: [Subject],
      terminate: [Subject],
      config: [Object],
      'data$': [Observable],
      'connected$': [Observable],
      'timeout$': [Observable],
      'error$': [Observable],
      'espData$': [Observable],
      socket: [Socket]
    },
    state: BehaviorSubject {
      closed: false,
      observers: [Array],
      isStopped: false,
      hasError: false,
      thrownError: null,
      _value: undefined
    },
    terminatePreviousStateSubscription: Subject {
      closed: false,
      observers: [Array],
      isStopped: false,
      hasError: false,
      thrownError: null
    },
    teardown: Subject {
      closed: false,
      observers: [Array],
      isStopped: false,
      hasError: false,
      thrownError: null
    },
    commandInPipeline: BehaviorSubject {
      closed: false,
      observers: [Array],
      isStopped: false,
      hasError: false,
      thrownError: null,
      _value: false
    },
    'state$': AnonymousSubject {
      closed: false,
      observers: [],
      isStopped: false,
      hasError: false,
      thrownError: null,
      destination: [BehaviorSubject],
      source: [BehaviorSubject],
      operator: [Function (anonymous)]
    }
  }
} []

Config:

{
    "devices": [
        {
            "host": "rfannative.local"
        }
    ],
    "debug": true,
    "platform": "esphome"
}
rithask commented 2 years ago

Looking at ESPHome logs, I found something interesting. Every next commands are only send exactly 30s after the first command.

[15:12:36][D][api.connection:727]: esphome-ts (192.168.1.2): Connected successfully
[15:12:41][D][remote_transmitter:066]: Sending remote code...
[15:12:41][D][mqtt.fan:092]: 'rfan' Sending state OFF.
[15:12:41][D][speed.fan:035]: Setting speed: 0.00
[15:12:41][D][speed.fan:046]: Setting oscillation: OFF
[15:13:11][D][remote_transmitter:066]: Sending remote code...
[15:13:11][D][remote_transmitter:066]: Sending remote code...
[15:13:11][D][mqtt.fan:092]: 'rfan' Sending state ON.
[15:13:11][D][speed.fan:035]: Setting speed: 0.67
[15:13:11][D][speed.fan:046]: Setting oscillation: OFF
[15:13:41][D][remote_transmitter:066]: Sending remote code...
[15:13:41][D][remote_transmitter:066]: Sending remote code...
[15:13:41][D][mqtt.fan:092]: 'rfan' Sending state OFF.
[15:13:41][D][speed.fan:035]: Setting speed: 0.00
[15:13:41][D][speed.fan:046]: Setting oscillation: OFF
[15:14:11][D][remote_transmitter:066]: Sending remote code...
[15:14:11][D][remote_transmitter:066]: Sending remote code...
[15:14:11][D][mqtt.fan:092]: 'rfan' Sending state ON.
[15:14:11][D][speed.fan:035]: Setting speed: 0.67
[15:14:11][D][speed.fan:046]: Setting oscillation: OFF
lucavb commented 2 years ago

No, with the debug option on, the plugin is going to generate a file under /tmp. I would like to see that one. Although the hint of 30s is an indication. There is a timeout that matches that duration.