jesserockz / wizmote-esphome

Apache License 2.0
66 stars 30 forks source link

No events on the bus #19

Open devinalonzo opened 11 months ago

devinalonzo commented 11 months ago

For a few months I have not been getting events from the esp to the home assistant event bus. In the esplogger I can see the button presses but not under the "developer tools - events - listen to events". I tried flashing all the default code to the esp. Not sure if it was an update that broke it or if I did something or what. Any ideas?

traxeon commented 9 months ago

I am able to see events on the bus. Listen to events - use one of the two below and click on start listening. Or use * to listen to all message and "start listening" and they should appear.

esphome.wizmote_action
esphome.wizmote_choose

When setting up the firmware in ESPhome, make sure to APPEND the code from "ESPHome configuration snippet" to the default code generated for ESPhome. Then flash the ESP32.

traxeon commented 9 months ago

I wont lie. Using this integration was difficult to figure out, but I'm super grateful someone built it. If you want to use the automation, here is a simple YAML that will toggle a light. When adding your mac address, make sure not to include the colons - you'll see the right format from the event history. Remember to change the event_type for the buttons as they appear as wizmote_choose events. Again, check the event logs and you'll see for each button what you need.

alias: Test wizmote events
description: "Use for turning on and off device only"
trigger:
  - platform: event
    event_type: esphome.wizmote_action
    event_data:
      device_id: <replace_with_your_device_id_from_event_log>
      mac: <replace_with_your_mac_from_wizmote_log_data>
      button: "1"
    id: wizmote_button_on
  - platform: event
    event_type: esphome.wizmote_action
    event_data:
      device_id: <replace_with_your_device_id_from_event_log>
      mac: <replace_with_your_mac_from_wizmote_log_data>8f7
      button: "2"
    id: wizmote_button_off
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - wizmote_button_on
        sequence:
          - type: turn_on
            device_id: bb24fc41acc6a68faeed97a52a826a34
            entity_id: 00522b0237c1928cf5fcff97fa245926
            domain: switch
      - conditions:
          - condition: trigger
            id:
              - wizmote_button_off
        sequence:
          - type: turn_off
            device_id: bb24fc41acc6a68faeed97a52a826a34
            entity_id: 00522b0237c1928cf5fcff97fa245926
            domain: switch
mode: single
Version Information
Core 2024.1.3
Supervisor 2023.12.1
Operating System 11.4
Frontend 20240104.0
ESPHome 2023.12.7
traxeon commented 9 months ago

Here is a blueprint for sending WIZMote events to MQTT if you want to use that: https://raw.githubusercontent.com/traxeon/hass/main/bp_wizmote_to_mqtt.yml

ImaZen88 commented 7 months ago

Hello, do you know how to change IDs, for the buttons, I would like to use this on Wiz smart button: Also I can see logs in the ESPHome integration, but there are no logs in event log on esphome.wizmote_action nor esphome.wizmote_choose.

this is my .yaml:

esphome:
  name: wiz-bridge
  friendly_name: wiz-bridge

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "1x6vW9uDccJbWrdPja9P0ElthJ7Exd4bc5vYzdhMNHY="

ota:

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wiz-Bridge Fallback Hotspot"

captive_portal:

external_components:
  - source: github://jesserockz/wizmote-esphome
    components:
      - esp_now
      - wizmote

esp_now:

wizmote:
  on_button:
    if:
      condition:
        lambda: return data.button >= 16 && data.button <= 19;
      then:
        - homeassistant.event:
            event: esphome.wizmote_choose
            data:
              mac: !lambda 'return format_hex(data.bssid, 6);'
              button: !lambda 'return data.button;'
              sequence: !lambda 'return data.sequence;'
      else:
        - homeassistant.event:
            event: esphome.wizmote_action
            data:
              mac: !lambda 'return format_hex(data.bssid, 6);'
              button: !lambda 'return data.button;'
              sequence: !lambda 'return data.sequence;'