jesserockz / wizmote-esphome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do you know how to get the MAC address for the wizmote?

jesserockz opened this issue Β· comments

Do you know how to get the MAC address for the wizmote?

Originally posted by @leovilela2 in #2 (comment)

@leovilela2 If you have the component set up, then it will be included in the event payload to Home Assistant.

...
mac: !lambda 'return format_hex(data.bssid, 6);'

Pardon my ignorance but does one need a ESP32 board dedicated to capture the wizmote packets or can Home Assistant's ESPHome do that?

Pardon my ignorance but does one need a ESP32 board dedicated to capture the wizmote packets or can Home Assistant's ESPHome do that?

did you manage to find out? I can't wrap my head around how to make this work

Just asking:
how to set up the component the correct way?
Is there a guide for beginners like me somewhere?`
I installed the blueprint to my HA Installation > I created a blank ESPHome configuration with my nodeMCU32 and have no button Presses seen here.

#edit: and which format does the mac adress need? AA:BB:CC:DD:EE:FF; aabbccddeeff or aa-bb-cc-dd-ee-ff

Found it:
We need to install the snippet in the README.md inside of our ESPHome configuration.
I created a PullRequest to get this clarified:
#10

After I installed the new ESP Configuration i could see in the log output of my ESP the MAC from the Wizmote.

It comes as A1.B2.C3.D4.E5.F6 but i converted it to A1B2C3D4E5E6 and added it inside the Blueprint Config
Now I can Control the devices.

@PlanetSmasher

Could You explain how to do it well step by step - for total beginner with esp? Perhaps you could share your remote file "wizmote.yaml" and other things you did.

Will sure do.
Maybe this weekend, when i got more time to spare

I'm still waiting patiently :)

Hi,
sorry it took me longer to get a free timeslot.

I try my best to get you started.

This is the way I was doing it. You can adapt it to your style.

I used Home Assistant with the following Addons installed:
- ESPHome

You can edit the Configuration file later with the Buildin Editor of ESPHome or via VSCode or SSH.

Installation of the blueprint

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Installation on ESP32 boards (e.g. NodeMCU-ESP32, Wemos D1 mini, and so on...)

In the ESPHome WebUI (Settings -> Add-ons -> ESPHome -> Start WebUI) I started with the Secrets File in the upper right corner.
There I Defined my IoT WiFi for all ESP Devices:

# Your Wi-Fi SSID and password
wifi_ssid: "ExampleWiFi"
wifi_password: "Use-only-secure-Passwords!"

Next, I pressed "New Device" gave it a Name, selected the Processor, Copied the encryption key and opened the new created config file.

On the WiFi Part I use:

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

After all prefilled configuration parts goes the config from here: ESPHome configuration snippet

Then it is time to plug the esp to the Computer and Install the configuration.
Keep in mind that this will not work with Firefox as only Chrome supports Web Serial. :-( 😒

Getting the MAC from the Wizmote

After the successful installation of the ESP device you can go into the logs and then after the first Part of the device config you can press one button on your Wizmote.

Example output:

INFO ESPHome 2023.12.3
INFO Reading configuration /config/esphome/testconfiguration.yaml...
INFO Starting log output from 123.456.789.203 using esphome API
INFO Successfully connected to wiz-test2 @ 123.456.789.203 in 0.024s
INFO Successful handshake with wiz-test2 @ 123.456.789.203 in 0.101s
[13:50:38][I][app:102]: ESPHome version 2023.10.3 compiled on Oct 26 2023, 12:15:19
[13:50:38][C][wifi:546]: WiFi:
[13:50:38][C][wifi:382]:   Local MAC: 12:34:56:78:9A:BC
[13:50:38][C][wifi:383]:   SSID: 'ExampleWiFi'[redacted]
[13:50:38][C][wifi:384]:   IP Address: 123.456.789.203
[13:50:38][C][wifi:386]:   BSSID: 11:22:33:44:55:66[redacted]
[13:50:38][C][wifi:387]:   Hostname: 'testconfiguration'
[13:50:38][C][wifi:389]:   Signal strength: -73 dB β–‚β–„β–†β–ˆ
[13:50:38][C][wifi:393]:   Channel: 1
[13:50:38][C][wifi:394]:   Subnet: 255.255.248.0
[13:50:38][C][wifi:395]:   Gateway: 123.456.789.1
[13:50:38][C][wifi:396]:   DNS1: 123.456.789.1
[13:50:38][C][wifi:397]:   DNS2: 0.0.0.0
[13:50:38][C][logger:416]: Logger:
[13:50:38][C][logger:417]:   Level: DEBUG
[13:50:38][C][logger:418]:   Log Baud Rate: 115200
[13:50:38][C][logger:420]:   Hardware UART: UART0
[13:50:38][C][copy.sensor:015]: Copy Sensor 'WiFi Signal Percent'
[13:50:38][C][copy.sensor:015]:   Device Class: 'signal_strength'
[13:50:38][C][copy.sensor:015]:   State Class: 'measurement'
[13:50:38][C][copy.sensor:015]:   Unit of Measurement: 'Signal %'
[13:50:38][C][copy.sensor:015]:   Accuracy Decimals: 0
[13:50:38][C][captive_portal:088]: Captive Portal:
[13:50:38][C][mdns:115]: mDNS:
[13:50:38][C][mdns:116]:   Hostname: testconfiguration
[13:50:38][C][ota:097]: Over-The-Air Updates:
[13:50:38][C][ota:098]:   Address: testconfiguration.local:3232
[13:50:38][C][ota:101]:   Using Password.
[13:50:38][C][api:138]: API Server:
[13:50:38][C][api:139]:   Address: testconfiguration.local:6053
[13:50:38][C][api:141]:   Using noise encryption: YES
[13:50:38][C][wifi_signal.sensor:009]: WiFi Signal 'WiFi Signal dB'
[13:50:38][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[13:50:38][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[13:50:38][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[13:50:38][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[13:50:38][C][esp_now:085]: esp_now:
[13:50:40][D][esp_now:072]: mac: 6C.29.90.AA.BB.CC (6), data: 81.FE.07.00.00.20.10.01.07.3E.F2.49.A1 (13)
[13:50:40][D][esp_now:072]: mac: 6C.29.90.AA.BB.CC (6), data: 81.FE.07.00.00.20.10.01.07.3E.F2.49.A1 (13)
[13:50:40][D][esp_now:072]: mac: 6C.29.90.AA.BB.CC (6), data: 81.FE.07.00.00.20.10.01.07.3E.F2.49.A1 (13)
[13:50:43][D][sensor:094]: 'WiFi Signal dB': Sending state -74.00000 dBm with 0 decimals of accuracy
[13:50:43][D][sensor:094]: 'WiFi Signal Percent': Sending state 52.00000 Signal % with 0 decimals of accuracy

And now we can start creating our automation using the Blueprint from the beginning.

Hi,

Thank you PlanetSmasher for the detailed instructions! Everything is clear except the part about connecting the ESP to the computer. Do you mean opening the remote control and connecting to the motherboard - GND, VCC, TX, RX, DO0 with a programmer (e.g. USB - UART to ESP8266 converter)?

Hi,
I've figured it out. We need an additional ESP device that will act as a gateway for wizmote. Thank you PlanetSmasher for your tips.

Hi, I'm trying to get a Wizmote configured, I've got an ESP32 device connected. Added the blueprint and tried to add the lines of code to the congiguration.yaml file but HA complains about the !lamda tag. I'm plainly missing something.

Thanks
Tom

"Configuration errors
Error loading /config/configuration.yaml: could not determine a constructor for the tag '!lambda'
in "/config/configuration.yaml", line 41, column 20"

Do it again with this tips:

  1. Import BLUEPRINT.
  2. Add your new esp device to ESPHome, next add device to HA.
  3. Edit yaml file from new device in ESPHome and copy everything starting from line "external_components:" from code here to your file.
  4. Install code to device.

Example code of a working gateway to wizmote. File configuration pilotwiz.yaml - based on e.g. ESP01s

esphome:
  name: pilotwiz
  friendly_name: pilotwiz

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "Kj0qWE9tCyyrKw592PmMXUD6Ii5qr6Jq4gnOwY+JU5Q="

ota:


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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Pilotwiz Fallback Hotspot"
    password: "x9Xc2hJVCkdc"
    
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 - 15;'
              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;'




If you want to operate the smart plug with a remote control like I do:

  1. Go to HA menu -> developer-tools/event and enter "esphome.wizmote_choose" in the "Listen to events" field
  2. Then click "Start Listening" and press a button on the remote control, for example button number 4
  3. An event will appear from which we copy several items to the newly created automation in HA settings.
event_type: esphome.wizmote_choose
data:
  device_id: e47f04c96eaf2b6afb919a2166fb66fb
  mac: 6c2990043603
  button: "4"
  sequence: "3042"
origin: LOCAL
time_fired: "2024-03-16T14:11:38.325150+00:00"
context:
  id: 01HS3SN6PN2PYS2R02GGK5PBR4
  parent_id: null
  user_id: null
  1. Edit automation in in YAML mode by clicking on the three dots in the upper right corner of the screen, next to traces
  2. Using previous data from the event, by clicking the button on the remote control, we prepare to operate smart plug, which will be turned on and off using button number 4

the automation yaml file configuration looks like this:

alias: Smart Plug Video HIFI
description: ""
trigger:
  - platform: event
    event_type: esphome.wizmote_choose
    event_data:
      device_id: e47f04c96eaf2b6afb919a2166fb66fb
      mac: 6c2990043603
      button: "4"
condition: []
action:
  - type: toggle
    device_id: be46e2beeb3e4a06a96c7ab763ad91f5
    entity_id: aeee747a314243b90bc94ad2479cea77
    domain: switch
mode: single

Good Luck!