Skip to content
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

SWITCHES (Switch / relay configuration) #365

Closed
xoseperez opened this issue Jan 2, 2018 · 14 comments
Closed

SWITCHES (Switch / relay configuration) #365

xoseperez opened this issue Jan 2, 2018 · 14 comments

Comments

@xoseperez
Copy link
Owner

Originally reported by: Adrian Liviu Lungeanu (Bitbucket: icevoodoo, GitHub: Unknown)


Hi,

There is a problem with boot mode settings for the relay.
No mather what I chose, after a reboot the relay is always ON.

The firmware is espurna-1.11.3.

@xoseperez
Copy link
Owner Author

This could be a duplicate of #341. What board are you using? Do you have the chance to grab the debug log on boot?

@xoseperez
Copy link
Owner Author

Original comment by Adrian Liviu Lungeanu (Bitbucket: icevoodoo, GitHub: Unknown):


Everything I can tell you about the device is below with a link with some pictures.
Regarding the debug log, can you tell me how to do it? There is some documentation about firmware espurna?

And I have a question, maybe i will put an issue about that. Can we have in espurna firmware in the future some thresholds for sensors (get/set) and a section where we can instruct the relay what to do if the thresholds are reached? I need this for a heating system to set it and forget it in case the device cannot reach the raspberry pi3 were i have the logic of the system...

https://photos.app.goo.gl/u52m1Q964VpY7M2u1

Sonoff TH10/16
ver. 2.1
AC 90 ~ 250W
2017-6-8

Manufacturer ITEAD
Device SONOFF_BASIC
Chip ID 81D60
MAC 5C:CF:7F:58:1D:60
Network VOODOO_24
IP 192.168.0.10
Firmware name ESPURNA
Firmware version 1.11.3
Firmware build 2018-01-02 14:33:00
Current time 2018-01-03 22:01:50
Uptime 0d 01h 34m 16s
Free heap 11576 bytes
Firmware size 494096 bytes
Free space 532480 bytes
MQTT Status CONNECTED
NTP Status SYNC'D

@xoseperez
Copy link
Owner Author

Issue #367 was marked as a duplicate of this issue.

@xoseperez
Copy link
Owner Author

Issue #375 was marked as a duplicate of this issue.

@xoseperez
Copy link
Owner Author

I can't reproduce this issue but other users have reported the same.

Can you please copy here the debug log of the device while booting?

@xoseperez
Copy link
Owner Author

Original comment by Wacko Madman (Bitbucket: wacko_madman, GitHub: Unknown):


on my Sonoff basic devices, boot mode is inverted after version 1.11.3, if set to ALWAYS ON, upon power up it briefly turns on then off, if set to ALWAYS OFF, on power up it stays ON

@xoseperez
Copy link
Owner Author

Hi @wacko_madman , can you please copy here the debug log of the device booting. Specially the relay module section. It should look something like this:

[RELAY] Retrieving mask: 0
[RELAY] Relay #0 boot mode 2
[RELAY] #0 set to OFF

On the first line it's the status mask retrieved from EEPROM. 0 means all relays OFF, 1 means relay 1 ON, 2 means relay 2 ON, 3 means relays 1 and 2 ON and so on.

On the second line it check the status of the relay boot mode. Relay boot modes are defined in general.h:

#define RELAY_BOOT_OFF          0
#define RELAY_BOOT_ON           1
#define RELAY_BOOT_SAME         2
#define RELAY_BOOT_TOGGLE       3

So in this case relay boot mode is "Same as before" and the mask says it was OFF so the relay is set ot OFF.

@xoseperez
Copy link
Owner Author

Original comment by chryss (Bitbucket: chryss, GitHub: chryss):


Hi Xose,

That is the boot log of 1.11.4 on Sonoff Basic

#!arduino

[MAIN] System OK
[WEBSOCKET] Parsing configuration data
[NTP] Error: NTP server not reachable
[MQTT] Unsubscribing to domoticz/out (PID 5)
[MQTT] Disconnecting
[MQTT] TCP Disconnected
[MQTT] Disconnected!
[MQTT] Connecting to broker at 192.168.44.97:1883
[MQTT] Client ID: ESPURNA_2ED1B0
[MQTT] QoS: 0
[MQTT] Retain flag: 1
[MQTT] Will topic: Sonoff_0/status
[MQTT] Connected!
[MQTT] Unsubscribing to # (PID 1)
[MQTT] Subscribing to Sonoff_0/relay/+/set (PID 2)
[MQTT] Subscribing to Sonoff_0/led/+/set (PID 3)
[MQTT] Subscribing to Sonoff_0/action/set (PID 4)
[MQTT] Sending Sonoff_0/data => {"app":"ESPURNA","version":"1.11.4","host":"Sonoff_0","ip":"192.168.44.60","mac":"2C:3A:E8:2E:D1:B0","rssi":"-56","uptime":"68","datetime":"Not set","freeheap":"20408","relay/0":"1"} (PID 1)
[MQTT] Sending Sonoff_0/status => 1 (PID 1)
[MAIN] Time: Not set
[HA] Sending autodiscovery MQTT message
[MQTT] Sending homeassistant/switch/Sonoff_0/config =>  (PID 1)
[MQTT] Sending Sonoff_0/status => 1 (PID 1)
[MQTT] Sending Sonoff_0/data => {"vcc":"4094","host":"Sonoff_0","ip":"192.168.44.60"} (PID 1)
[MQTT] Subscribe ACK for PID 2
[MQTT] Received Sonoff_0/relay/0/set => 0 - SKIPPED
[MQTT] Subscribe ACK for PID 3
[MQTT] Subscribe ACK for PID 4
[NTP] Time: 2018-01-10 23:07:33

@xoseperez
Copy link
Owner Author

Thanks @chryss, but I need the log before that. The "System OK" line happens at 60 seconds after boot. Mind the module initialization happens before it gets connected to the router so you will need to have it wired to see the log.

@xoseperez
Copy link
Owner Author

Original comment by chryss (Bitbucket: chryss, GitHub: chryss):


Yes, i have forgotten since last time.....i'm old man :-)

#!arduino

[INIT] ESPURNA 1.11.4
[INIT] xose.perez@gmail.com
[INIT] http://tinkerman.cat

[INIT] CPU chip ID: 0x2ED1B0
[INIT] CPU frequency: 80 MHz
[INIT] SDK version: 1.5.3(aec24ac9)
[INIT] Core version: 2_3_0
[INIT] Core revision: 

[INIT] Flash chip ID: 0x14405E
[INIT] Flash speed: 40000000 Hz
[INIT] Flash mode: DOUT

[INIT] Flash sector size:     4096 bytes
[INIT] Flash size (CHIP):  1048576 bytes
[INIT] Flash size (SDK):   1048576 bytes /  256 sectors
[INIT] Firmware size:       454000 bytes /  111 sectors
[INIT] OTA size:            573440 bytes /  140 sectors
[INIT] SPIFFS size:              0 bytes /    0 sectors
[INIT] EEPROM size:           4096 bytes /    1 sectors
[INIT] Empty space:          16384 bytes /    4 sectors

[INIT] BOARD: ITEAD_SONOFF_BASIC
[INIT] SUPPORT: ALEXA DEBUG_SERIAL DEBUG_TELNET DOMOTICZ HOMEASSISTANT MDNS NTP TELNET TERMINAL THINGSPEAK WEB

[INIT] Last reset reason: Power on
[INIT] Free heap: 30024 bytes
[INIT] Power: 4094 mV
[INIT] Power saving delay value: 10 ms

[TELNET] Listening on port 23
[WEBSERVER] Webserver running on port 80
[RELAY] Retrieving mask: 1
[RELAY] Relay #0 boot mode 0
[RELAY] #0 set to OFF
[RELAY] Number of relays: 1
[BUTTON] Number of buttons: 2
[LED] Number of leds: 1
[MQTT] Async ENABLED, Autoconnect ENABLED
[THINGSPEAK] Async ENABLED, SSL DISABLED
[MAIN] Uptime: 0 seconds
[MAIN] Free heap: 24888 bytes
[MAIN] Power: 4094 mV
[MAIN] Time: Not set
[BUTTON] Button #1 event 2
[RELAY] #0 scheduled ON in 0 ms
[WIFI] Connecting to chryss House
[RELAY] #0 set to ON
[RELAY] Saving mask: 1
[MDNS] OK
[NTP] Error: NTP server not reachable
[WIFI] MODE STA -------------------------------------
[WIFI] SSID chryss House
[WIFI] IP   192.168.44.60
[WIFI] MAC  2C:3A:E8:2E:D1:B0
[WIFI] GW   192.168.44.254
[WIFI] DNS  192.168.44.254
[WIFI] MASK 255.255.255.0
[WIFI] HOST Sonoff_0
[WIFI] ----------------------------------------------
[MQTT] MQTT brokers found: 0
[MQTT] Connecting to broker at 192.168.44.97:1883
[MQTT] Client ID: ESPURNA_2ED1B0
[MQTT] QoS: 0
[MQTT] Retain flag: 1
[MQTT] Will topic: Sonoff_0/status
[MQTT] Connected!
[MQTT] Unsubscribing to # (PID 1)
[MQTT] Subscribing to Sonoff_0/relay/+/set (PID 2)
[MQTT] Subscribing to Sonoff_0/led/+/set (PID 3)
[MQTT] Subscribing to Sonoff_0/action/set (PID 4)
[MQTT] Sending Sonoff_0/data => {"app":"ESPURNA","version":"1.11.4","host":"Sonoff_0","ip":"192.168.44.60","mac":"2C:3A:E8:2E:D1:B0","rssi":"-57","uptime":"7","datetime":"Not set","freeheap":"24288","relay/0":"1"} (PID 1)
[MQTT] Sending Sonoff_0/status => 1 (PID 1)
[MAIN] Time: Not set
[HA] Sending autodiscovery MQTT message
[MQTT] Sending homeassistant/switch/Sonoff_0/config =>  (PID 1)
[MQTT] Sending Sonoff_0/status => 1 (PID 1)
[MQTT] Sending Sonoff_0/data => {"vcc":"4094","host":"Sonoff_0","ip":"192.168.44.60"} (PID 1)
[MQTT] Subscribe ACK for PID 2
[MQTT] Received Sonoff_0/relay/0/set => 0 - SKIPPED
[MQTT] Subscribe ACK for PID 3
[MQTT] Subscribe ACK for PID 4
[NTP] Time: 2018-01-10 23:21:33

Capture d’écran 2018-01-10 à 23.23.13.png
Capture d’écran 2018-01-10 à 23.23.31.png

@xoseperez
Copy link
Owner Author

Got it.

The relay init is fine. But then I see there are two buttons defined and the second one is triggering the relay ON. This is the seconday button on the header (GPIO14) and it was introduced in the definitions not long ago. Unfortunately it looks like I made a mistake, I defined it with an internal pull-up but forgot to specify it's normal state is high.

A fix for this could be changing the BUTTON2_MODE line in the hardware.h for the SONOFF_BASIC (around line 180) with this:

#define BUTTON2_MODE        BUTTON_SWITCH | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH

@xoseperez
Copy link
Owner Author

Released with 1.12.0

@xoseperez
Copy link
Owner Author

Removing milestone: 1.12.0 (automated comment)

@ghost
Copy link

ghost commented Sep 27, 2018

Seems like I am also experiencing the + naming for the relay. This breaks HASS compat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant