The config for that button can be simpler/more direct for that wire as it only uses one wire.
But it shouldn’t be triggered on boot. Mine doesn’t.
I don’t know what’s triggering it and am somewhat out of ideas.
Maybe try activating pullup or pulldown resistors for the pin?
And separately maybe try commenting out the existing on_boot code and see if that changes anything.
And triple check your wiring for that pin.
Also, I recall seeing similar issues on this forum “thing X turns on/off momentarily on restart/ boot”. So maybe dig around to see if you can find a similar issue/solution.
opened 09:30PM - 04 May 22 UTC
closed 05:21AM - 09 May 22 UTC
### The problem
I've been using ESPHome for almost a year now, mostly for switc… hes (on/off as well as power measurement). The switches are connected to PCs, routers, RPi 4 running home assistant, appliances (fridges, washing machine, dishwasher). The software has been rock solid and haven't had any issues.
Since version 2022.3.0 the behaviour of my switches changed: when updating the software or manually resetting the device from the web interface, switches/relays that are on at that point briefly switch off then on again. This has resulted in PCs switching off, my fridge beeping, washing & dishwasher cycles getting interrupted, internet connectivity loss, etc.
I first tried setting "restore_from_flash" to "true" and setting the "restore_mode" to "RESTORE_DEFAULT_ON" without success.
I then hooked up a scope to a D1 Mini and connected my probes to pins D4 (GPIO2 - internal LED) and D1 (GPIO5 - relay shield).
1. I verified that with release 2022.2.0
a. The relay remains powered on when restarting from the Web UI
b. The relay remains powered on when updating the firmware (I re-uploaded the 2022.2.0 bin).
In the image below, CH1 is connected to output D4, and CH2 is connected to the output D1.
![1_2022 02 0_web_restart_ch1d4_ch2D1](https://user-images.githubusercontent.com/29565637/166822875-f1c58dbc-a9e8-4dfc-9ed3-7e9238d9d5a3.png)
2. I verified that with release 2022.3.0:
a. The relay briefly switches off and back on when restarting from the Web UI
b. The relay briefly switches off and back off when updating the firmware (I re-uploaded the 2022.3.0 bin).
On the scope I saw where the restart occurred based on the LED Toggle. I could see that the output briefly dropped to ~0V
![2_2022 03 0_web_restart_ch1d4_ch2D1](https://user-images.githubusercontent.com/29565637/166823138-58fa9663-d41d-4a97-ba04-d9511e5d7704.png)
3. Next I wanted to make sure that I didn't miss a potential glitch. I set up a trigger on my scope on a falling edge when dropping below 3V.
a. With release 2022.2.0 the scope did not trigger when restarted from the Web UI or upgrading the firmware
b. With release 2022.3.0 the scope did trigger, and shows that the output remains at ~0V for approximately 19.2ms
The image below applies to 3b and shows output D1 toggling off and back on (moved from CH2 to CH1 in this setup)
![3_2022 03 0_restart_trigger](https://user-images.githubusercontent.com/29565637/166823906-f4d64bbe-7621-4860-b464-928af070dc79.png)
One last comment: eWelink and Tasmota also keep the switches on when performing a restarting
### Which version of ESPHome has the issue?
2022.3.0
### What type of installation are you using?
Home Assistant Add-on
### Which version of Home Assistant has the issue?
_No response_
### What platform are you using?
ESP8266
### Board
D1 Mini, Sonoff Basic R2, Sonoff Pow R2
### Component causing the issue
esp8266/core
### Example YAML snippet
```yaml
esphome:
name: examplenode
build_path: ./build/examplenode
esp8266:
board: d1_mini
captive_portal:
# Enable logging
logger:
level: debug
# Enable Home Assistant API
api:
ota:
# Create a web service listening on port 80
web_server:
port: 80
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
wifi:
networks:
- ssid: "Jarvis"
password: !secret wifi_password_jarvis
switch:
- platform: restart
name: "ExampleNode Restart"
- platform: gpio
name: "examplenode Switch"
id: gate_switch
pin: D1
binary_sensor:
- platform: status
name: "ExampleNode Status"
sensor:
- platform: uptime
name: "ExampleNode Uptime Sensor"
- platform: wifi_signal
name: "ExampleNode WiFi Signal"
update_interval: 60s
text_sensor:
- platform: wifi_info
ip_address:
name: ExampleNode IP Address
ssid:
name: ExampleNode Connected SSID
mac_address:
name: ExampleNode Mac Address
```
### Anything in the logs that might be useful for us?
```txt
Pins are reset before logging is available
```
### Additional information
See first Discord #dev post here:
https://discord.com/channels/429907082951524364/524177279270780928/969340482729701406
...and follow-up post here:
https://discord.com/channels/429907082951524364/524177279270780928/970053624845701130
From the second link:
> ...removing the following lines from core.cpp (src/esphome/components/esp8266) keeps the relay powered on when restarting via the web ui.
![core cpp](https://user-images.githubusercontent.com/29565637/166825354-3b82943f-9673-41bc-baa9-af34c2b7f74c.png)
>I do understand the original issue though - with a cold boot the pins are in an undefined state, and these should be set to something sensible.
>However, once the device has been powered on and is restarted while remaining powered on (whether this is due to lost wifi connection, upgrade, or manual reset), the pins were in a defined state before restart. I would think a device is more likely to restart than being completely switched off and back on again.
>In my opinion, especially for switches, outputs should remain powered on while restarting.
Just found this page, you could try early_pin_init: false
I just added it to a plug I have that clicks off-on on firmware update and this has stopped it doing that
Definitely look at early_pin_init
Anto79-ops
(Anto79 Ops)
March 20, 2023, 10:37pm
174
why you, sir, are a genius @Mahko_Mahko .
I read through all your suggestions but the last one made more sense so I started that first. I set early_pin_init: false
and after the board updated and came back online…no desk movement, and even when I rebooted the board manually, no desk movement! problem is solved! thank you
1 Like
wookash
(wookash)
April 22, 2023, 8:18pm
175
hi, I have a desk from a manufacturer where the motor control box has two RJ-45 ports. My question is - can I plug the DIY remote controller in the second RJ-45 slot or do I have to create a passthrough box - so that the original physical controller and the DIY one are on the same connection?
Is it a Jiecang based desk?
wookash
(wookash)
April 23, 2023, 12:25am
177
hello, it says manufacturer: Loctek ergonomic technology corp.
Then you are probably better off over here.
[image]
A while ago I purchased an electrical standing desk from Flexispot.de . During assembly I found out that the display controls are connected via a RJ45 cable to the motor control box, and that the motor control box even has a second RJ45 input.
Challenge accepted! How cool would it be if I can control my desk by voice or if I can pull statistics to understand if I stand too less. (like with my manual IKEA desk that I have used twice in four years…)
[image]
The first step was to open …
Where I can see you’ve asked the same question…
wookash
(wookash)
April 23, 2023, 8:35am
179
Yeah, however, did not hey any response there yet and since then I realized that I actually have the motor from the same vendor. Anyway, my question was a bit generic - if having two rj45 ports pass through is the only way.
Thanks, anyway.
estley
(Esteban Ley)
May 11, 2023, 12:27am
180
So I got this working a while ago and it’s been amazing. I’m trying to integrate it with some other stuff, and now I’d like to trigger automations based on the direction the desk is moving.
Is there a way to tell? The only way I can think of doing that is comparing the current height a second ago, but I have no clue how to do that.
1 Like
If you are moving the desk using the move_to command…
on_...:
then:
- lambda: id(my_desky).move_to(150);
Then you can make use of the DESKY_OPERATION feature that Ssieb kindly built at my request. Also see this bit. They were inspired by thier cover equivalents (COVER_OPERATION_OPENING, COVER_OPERATION_CLOSING)
How ever this feature won’t report direction if you use the desks native contoller or trigger the memory buttons via ESPHome.
I recently worked around this by basically doing what you’ve suggested, which is watch for changes in height.
My implementation is bascially a “delta sensor”. There’s probably a better way to do this but it’s ok for my purpose for the moment.
Make sense?
- platform: copy
source_id: desky_height_cm
id: desky_height_cm_delta
name: "Desky Desk Height Delta"
accuracy_decimals: 1
internal: true
icon: mdi:arrow-expand-vertical
unit_of_measurement: cm
filters:
#Convert to Delta
- lambda: |-
static float last_value = 0;
float change = 0;
change = x - last_value;
last_value = x;
return change;
on_value:
then:
- lambda: |-
if ( x > 0){ return id(desky_last_movement_direction).publish_state("Up");}
else if (x < 0){return id(desky_last_movement_direction).publish_state("Down"); }
- lambda: |-
if (id(desky_height_cm_delta).state != 0) {
id(desky_is_moving).publish_state(true);
}
- delay: 200ms
- lambda: return id(desky_is_moving).publish_state(false);
binary_sensor:
- platform: template
id: desky_is_moving
name: Desky Is Moving
# lambda: return id(my_desky).current_operation != desky::DESKY_OPERATION_IDLE;
icon: "mdi:motion"
filters:
- delayed_off: 1s
estley
(Esteban Ley)
May 11, 2023, 10:03am
182
Interesting, I’ll give it a try, thanks!
1 Like
jaddel
(Jaddel)
June 4, 2023, 9:34am
183
Can anyone report success with a MAIDeSITe desk?
All desks so far have had Jiecang controllers. Have you done any digging to check whether this is a Jiecang controller? I think it’s pretty unlikely.
jaddel
(Jaddel)
June 4, 2023, 9:53am
185
Acutally no, my main concern until now was the construction of the frame regarding stability. The MAIDeSITe desk seemed to be the most stiff compared to others.
Maybe this works: Turn your LoctekMotion/FlexiSpot standing desk into a smart desk! - #36 by m1scha
I’ll check the hardware once the desk arives and report about it.
1 Like
That’s probably the best idea. Don’t be too afraid to unscrew the controller box and take a peak at the board inside (although taking apart that may void your warranty). Even just Google imaging the control box and control panel you can often find out who the OEM is, which is the secret to finding the right project which will work or can be adapted.
jaddel
(Jaddel)
June 4, 2023, 10:27am
187
Okay, thanks! Here are some close-up pictures. Can you possibly determine from the outward appearance if it is supported?
I think you will be in luck!
I would buy parts.
It’s possible the newer Jiecang controllers may have a different or slightly different protocol, but this is looking pretty promising as a start!
The hardware looks quite similar!
1 Like
jaddel
(Jaddel)
June 4, 2023, 10:51am
189
Great, thank you so much for taking the the time!
1 Like
jaddel
(Jaddel)
June 6, 2023, 8:58am
190
I have just received the desk and checked everything. Although it is manufactured by Jiecang, the controller seems to be different. Here are some additional pictures of the MaideSite desk.
There is one 6 wire RJ-12 connector that’s directly connected to the control box. Maybe I can hock up the esp there?
Could you send more photos please? Perhaps similar to those in this post. Or a vid.
Just want to get a clearer picture of the system diagram.
Also see if you can spot your controller here.
jaddel
(Jaddel)
June 6, 2023, 9:39am
192
I couldn’t find the controller in the list you shared. It appears that the motor drivers are integrated with the display.
Here are some pictures and the wiring diagram. Each leg and power are directly connected to the touch display box.