-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code not optimised for multiple remotes. #14
Comments
Someone had the same suggestion in the past here: #4 (comment) Looks like it never made it into the code, though. |
seen and good pickup. For anyone who it trying to used multiple remotes you can edit the file through the HA file editor (after the first time that the ESP has been updated). For me the file was at: /config/esphome/.esphome/external_components/343b74af/components/wizmote/wizmote.cpp |
Looks like today Jesse merged my PR (#9 ) which fixes this and supports up to 15 remotes simultaneously (this limit is easily changed by modifying a define). |
Hey, I have a question. I can't get the wizmote to work. I have an ESP32 with this code: esphome:
name: wizmote
friendly_name: wizmote
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "secrid"
ota:
password: "secrid"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Wizmote Fallback Hotspot"
password: "secrid"
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;' And I'm using the blueprint, but when I click on button 1, the lamp doesn't turn on. I've entered the correct MAC address, so what's wrong? |
Let me take a look at my blue print. It's been several months since I did this change, but I seem to recall the stock blueprint didn't work as is after the change. Might be wrong with that. I'll test my known working setup against the stock blueprint and get back to you. |
That's good because I really want to use it, especially with button 1 for single click, double click, and triple click; it would have a lot of options then! |
As a note, I never made a blueprint that supports double or triple click. But there is technically no reason why it can't be made, but you'll need to make a blueprint for that one yourself. The modifications I made to the blueprint simply allowed for a default group so if a group selection hasn't been made, it will default to whatever group I set. My wife got annoyed pressing the on button and the lights not turning on. So I just made the lights the default group for the blueprint |
Glad you found the issue. Regarding the blueprint for detecting double clicks: the way that I would tackle it is the following: The blueprint has a "choose" event listener. You can have a loop that triggers off additional choose events or an action event (up/down/sleep). Each trigger event contains a timestamp and the button pressed. So I would do the math to detect the time between presses from the timestamp flag and see if it is less than a double click threshold (maybe 0.5 second?). The blueprint mode will need to be single in order to detect this. I am away from my home assistant instance for the rest of the week so I cannot take a stab at some logic. I did some searching and found this thread about how to detect multiple clicks from a binary sensor. This is similar except it's a home assistant event and you will need to verify that the button press is the same as previously pressed. |
wizmote.cpp having the following:
if (wizmote.sequence <= this->last_sequence_)
return;
prevents the effective use of multiple remotes. In short this bit of code will only allow the remote with the highest sequence to record events in HA. I recommend changing to the following:
if (wizmote.sequence == this->last_sequence_)
return;
This code will prevent rapid multi call of the events whilst also allowing multiple remotes to be used.
The text was updated successfully, but these errors were encountered: