Sunday, 21 July 2019

Problems with Extension Zone MV

Sent on Sunday 21st July 2019 over WhatsApp to Kilnageer CH group:

Hi Fellas. I'm trying to use CH for extension zone tonight but the "Extension Zone" SonOff keeps going to off (after 5 mins or so)
As I mentioned before this is due to it losing Wifi to Vodafone-2124 and reseting. I'm investigating.
..Happy days. Setting "retained" flag to on for the "Extension Zone" MQTT Dash app button ensures wifi drop outs on its SonOff restore the correct settings.
This falg was set for all the other MQTT Dash buttons so you would not have been aware of this issue.
Liam. Any progress on programming Node-Red for a 15 minute timer or based on your room temperature probe? As I need this now for the Extension Zone :)
Up Mayo! :) Donegal next!

Here's the details:

2C:3A:E8:07:B8:4F       192.168.1.101 Extension Zone MV
B8:27:EB:C8:19:85       192.168.1.100 Raspberry Pi Controller
2C:3A:E8:0F:4D:99       192.168.1.104 Cylinder MV
2C:3A:E8:0F:4C:E8       192.168.1.103 Sleeping Zone
EC:FA:BC:86:D5:E4       192.168.1.105 Oil Burner and Pump
2C:3A:E8:4F:4D:02       192.168.1.106 Living Zone
5C:CF:7F:67:29:50       192.168.1.107 Shower Pump

Looking at console log for Extension Zone I see when it loses Wifi and
turns itself off:
18:54:38 DNS: Initialized
18:54:39 MQT: Attempting connection...
18:54:39 MQT: Connected
18:54:39 MQT: tele/sonoff_6223/LWT = Online (retained)
18:54:39 MQT: cmnd/sonoff_6223/POWER =
18:54:39 MQT: stat/sonoff_6223/RESULT = {"POWER":"OFF"}
18:54:39 MQT: stat/sonoff_6223/POWER = OFF (retained)


Then when MQTT Dash app turns it on I see:
18:55:12 DNS: Initialized
18:55:13 MQT: Attempting connection...
18:55:13 MQT: Connected
18:55:13 MQT: tele/sonoff_6223/LWT = Online (retained)
18:55:13 MQT: cmnd/sonoff_6223/POWER =
18:55:13 MQT: stat/sonoff_6223/RESULT = {"POWER":"OFF"}
18:55:13 MQT: stat/sonoff_6223/POWER = OFF (retained)
18:55:31 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
18:55:31 MQT: stat/sonoff_6223/POWER = ON (retained)

Then I used 192.168.1.100:1880/ui to turn the extension zone on:

19:02:37 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
19:02:37 MQT: stat/sonoff_6223/POWER = ON (retained)

Which is causing SonOff to update its retained settings! So now when
it loses connection it comes back as ON (rather than OFF)

19:03:05 MQT: Attempting connection...
19:03:05 MQT: Connect failed to 192.168.1.100:1883, rc -2. Retry in 10 sec
19:03:05 WIF: Connecting to AP1 vodafone-2124 in mode 11N as sonoff_6223-6223...
19:03:09 WIF: Connected
19:03:09 DNS: Initialized
19:03:20 MQT: Attempting connection...
19:03:20 MQT: Connected
19:03:20 MQT: tele/sonoff_6223/LWT = Online (retained)
19:03:20 MQT: cmnd/sonoff_6223/POWER =
19:03:20 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
19:03:20 MQT: stat/sonoff_6223/POWER = ON (retained)
19:03:26 MQT: tele/sonoff_6223/STATE =
{"Time":"2019-07-21T19:03:26",
"Uptime":"15T11:21:44","Vcc":3.476,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER":"ON","Wifi":{"AP":1,"SSId":"vodafone-2124","BSSId":"D0:FF:98:1B:31:3C","Channel":9,"RSSI":78}}
19:05:29 DNS: Initialized
19:05:30 MQT: Attempting connection...
19:05:30 MQT: Connected
19:05:30 MQT: tele/sonoff_6223/LWT = Online (retained)
19:05:30 MQT: cmnd/sonoff_6223/POWER =
19:05:30 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
19:05:30 MQT: stat/sonoff_6223/POWER = ON (retained)

So I set the Retained flag in MQTT Dash app for the "Extension Zone"
and now when I set it from there..

Turning off from Node-Red..
19:06:54 MQT: stat/sonoff_6223/POWER = ON (retained)
19:08:06 MQT: Attempting connection...
19:08:06 MQT: Connect failed to 192.168.1.100:1883, rc -2. Retry in 10 sec
19:08:09 DNS: Initialized
19:08:20 MQT: Attempting connection...
19:08:20 MQT: Connected
19:08:20 MQT: tele/sonoff_6223/LWT = Online (retained)
19:08:20 MQT: cmnd/sonoff_6223/POWER =
19:08:20 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
19:08:20 MQT: stat/sonoff_6223/POWER = ON (retained)
19:08:26 MQT: tele/sonoff_6223/STATE =
{"Time":"2019-07-21T19:08:26","Uptime":"15T11:26:44","Vcc":3.495,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER":"ON","Wifi":{"AP":1,"SSId":"vodafone-2124","BSSId":"D0:FF:98:1B:31:3C","Channel":9,"RSSI":80}}
19:08:45 DNS: Initialized
19:08:46 MQT: Attempting connection...
19:08:46 MQT: Connected
19:08:46 MQT: tele/sonoff_6223/LWT = Online (retained)
19:08:46 MQT: cmnd/sonoff_6223/POWER =
19:08:46 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
19:08:46 MQT: stat/sonoff_6223/POWER = ON (retained)
..
19:09:22 MQT: stat/sonoff_6223/RESULT = {"POWER":"OFF"}
19:09:22 MQT: stat/sonoff_6223/POWER = OFF (retained)
..

And so it stays like this (OFF) after Wifi loss..

19:46:26 MQT: stat/sonoff_6223/RESULT = {"POWER":"OFF"}
19:46:26 MQT: stat/sonoff_6223/POWER = OFF (retained)
19:47:21 WIF: Connecting to AP1 vodafone-2124 in mode 11N as sonoff_6223-6223...
19:47:25 WIF: Connected
19:47:25 DNS: Initialized
19:47:26 MQT: Attempting connection...
19:47:26 MQT: Connected
19:47:26 MQT: tele/sonoff_6223/LWT = Online (retained)
19:47:26 MQT: cmnd/sonoff_6223/POWER =
19:47:26 MQT: stat/sonoff_6223/RESULT = {"POWER":"OFF"}
19:47:26 MQT: stat/sonoff_6223/POWER = OFF (retained)

turned on retained..
19:47:46 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
19:47:46 MQT: stat/sonoff_6223/POWER = ON (retained)

next drop out..
19:48:04 MQT: Attempting connection...
19:48:04 MQT: Connect failed to 192.168.1.100:1883, rc -2. Retry in 10 sec
19:48:05 WIF: Connecting to AP1 vodafone-2124 in mode 11N as sonoff_6223-6223...
19:48:09 WIF: Connected
19:48:09 DNS: Initialized
19:48:20 MQT: Attempting connection...
19:48:20 MQT: Connected
19:48:20 MQT: tele/sonoff_6223/LWT = Online (retained)
19:48:20 MQT: cmnd/sonoff_6223/POWER =
19:48:20 MQT: stat/sonoff_6223/RESULT = {"POWER":"ON"}
19:48:20 MQT: stat/sonoff_6223/POWER = ON (retained)
19:48:26 MQT: tele/sonoff_6223/STATE =
{"Time":"2019-07-21T19:48:26","Uptime":"15T12:06:44","Vcc":3.478,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER":"ON","Wifi":{"AP":1,"SSId":"vodafone-2124","BSSId":"D0:FF:98:1B:31:3C","Channel":9,"RSSI":70}}

Happy days it stays on.

Was going to set it for all other MQTT Dash buttons - but it was already set!!!

Friday, 28 June 2019

Solar Panels (3 of 5) back online!

Finally wired up the batteries in the attic again in Weds night. By Thurs when I left Mayo I had charged up all three 24v sets :)




And was getting about 30% of maximum with 3 of 5 panels wired up.

Must get inverter and other two panels working next time I'm up. Also make a remote panel meter replacement with NodeMcu :)

3 of 5 240W panels (24v @10A) wired in series to a charge controller which displays status on a meter. Just one (of three) 24V battery pair wired up and broken inverter turned off.

EPsolar Tracer 2215BN MPPT Solar Charge Controller Regulator 20A + Remote MT-50

6x 110Ah 12v car batteries. So 4KWh buffer (as only 50% of lead acid battery can discharged).


Sunday, 5 May 2019

I have been watching youtube videos by Andreas Spiess of late. He's brilliant and very thorough!

Tonight I'm working through his Arduino IDE vs PlatformIO video at:
https://www.youtube.com/watch?v=0poh_2rBq7E&list=PL3XBzmAj53Rlu3Byy_GkqG6b-nwEpWku0&index=45&t=0s

So I launched Arduino IDE from the Win 10 search box "arduino" .. and as it was v 1.8.8 I left it as that (even though 1.8.9 is now available)

I then installed Visual Studio Code (VSC) from:
https://visualstudio.microsoft.com/downloads/

Then followed his video to install PlatformIO from VSC. It automatically also installed the C/C++ extension.

I then created a New Project choosing the board: 
[env:nodemcu]
platform = espressif8266
board = nodemcu
framework = arduino
From platformio.ini file.

I made a blink program and run it but only the serial output at 9600 baud worked. The LED_BUILTIN didn't blink :(

Moved on to using MQTT but need nodemcu to use vodafone-2124 SSID and rasp pi too as MQTT broker (to mimic Kilnageer LAN) but laptop to use Eir router as normal in Tola!

So how can I have a terminal to rasp pi? Use NC-10? Or even mobile phon eor tablet as only need to see it's up and running and check on output.

So "mayo_rpi_logger_2_Wireless" must move from 192.168.1.141 to vodafone-2124 LAN! Will do tomorrow afternoon.





Wednesday, 17 April 2019

Sonoff restart concerns

I just posted this to the WhatsApp "Kilnageer CH 2019" for Bren and Liam to consider.

"I have concerns regarding what state the sonoffs power up into and/or restore after a reboot or wifi drop. See this excellent article:
http://www.thesmarthomehookup.com/end-random-ghost-switching-for-good-by-fixing-your-retain-settings-in-tasmota-and-home-assistant/

I think the safest but least elegant solution is to configure the sonoffs to power up/restart in off but for their controllers (Node-Red web  MQTT Dash android app) to publish retained to a shadow topic. And for a Node-Red script to loop every 5 secs to ensure the sonoffs follow these user defined shadow values.

This script can also check for safety concerns and take action. For example, if burner is on but no zones/cylinder to turn it off and e-mail registered users.

I'm setting up a spare router in Shannon to mimic the Kilnageer set-up so I can experient with this solution here before deploying in Kilnageer next visit.

Any questions/suggestions?"



Tuesday, 16 April 2019

Will demo sonoff/tasmota light switch in the Men's Shed this morning

https://github.com/arendst/Sonoff-Tasmota/wiki/Button-usage

So three short presses gets the SSID menu up on SSID sonoff_3536-3536 and IP 192.168.4.1

Then got tablet and sonoff to connect to MensShed hotspot (no internet) provided by phone.

192.168.43.103 is the sonoff when its using the MensShed SSID

Sunday, 14 April 2019

Switching from Lua to micro Python to get MQTT connect on NodeMcu to work..

(7:48) rad 11.5 / 10.6 manually turn on zone and burner

(8:11) rad 49.8 / 12.8

Why isn't MQTT Dash updating the icon status every few minutes?



Current Eir router LAN map

5C:CF:7F:40:CD:D0_Wireless 5C:CF:7F:40:CD:D0 192.168.1.100 Tony's Lamp (3536)
2C:3A:E8:07:B8:4F_Wireless 2C:3A:E8:07:B8:4F 192.168.1.103  Extension zone MV (6223)
2C:3A:E8:0F:4D:99_Wireless 2C:3A:E8:0F:4D:99 192.168.1.102 Cylinder MV (3481)
2C:3A:E8:0F:4C:E8_Wireless 2C:3A:E8:0F:4C:E8 192.168.1.101  Bedroom zone MV (3304)
EC:FA:BC:86:D5:E4_Wireless EC:FA:BC:86:D5:E4 192.168.1.108 Oil burner (5604)
2C:3A:E8:4F:4D:02_Wireless 2C:3A:E8:4F:4D:02 192.168.1.106  Living zone MV (3330)
5C:CF:7F:67:29:50_Wireless 5C:CF:7F:67:29:50 192.168.1.107  Shower pump (2384)

(8:11) rad 47.1 / 15.4 burner was off so put it back on

Currently, MQTT Dash is subscribing to "stat/sonoff_6223/POWER"  which is "ON" or "OFF" but will only see last value.

But needs to subscribe to "tele/sonoff_6223/STATE" which is published every 5 mins (300 secs) as:
{"Time":"2019-04-14T08:42:33","Uptime":"0T11:33:24","Vcc":3.495,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER":"ON","Wifi":{"AP":1,"SSId":"vodafone-2124","BSSId":"D0:FF:98:1B:31:3C","Channel":9,"RSSI":76}}

And to change this period on each sonoff to 5 secs. But what script will extract the "ON" field?

(8:49) rad 47.8 / 16.1 but my hands are still cold

(9:25) rad 30.9 / 16.1 (I was messing with MQTT Dash and turned off zone by accident)

Made all seven sonoff static IPs in Eir router (are lamp IP jumped after reboot!)
5C:CF:7F:40:CD:D0_Ethernet 5C:CF:7F:40:CD:D0 192.168.1.115 Tony's Lamp (3536)
2C:3A:E8:07:B8:4F_Wireless 2C:3A:E8:07:B8:4F 192.168.1.101  Extension zone MV (6223)
2C:3A:E8:0F:4D:99_Wireless 2C:3A:E8:0F:4D:99 192.168.1.116 Cylinder MV (3481)
2C:3A:E8:0F:4C:E8_Wireless 2C:3A:E8:0F:4C:E8 192.168.1.103  Bedroom zone MV (3304)
EC:FA:BC:86:D5:E4_Wireless EC:FA:BC:86:D5:E4 192.168.1.105 Oil burner (5604)
2C:3A:E8:4F:4D:02_Wireless 2C:3A:E8:4F:4D:02 192.168.1.106  Living zone MV (3330)
5C:CF:7F:67:29:50_Wireless 5C:CF:7F:67:29:50 192.168.1.107  Shower pump (2384)

(9:57) rad 32.0 / 16.2 (zone was off again!)

"event.payload" no good in "on receive" displays nothing!
"POWER" causes an error message which is something I suppose
"event[POWER]" same message
"print event" missing ; before statement
"print( event );" - print is not defined
"print event ;" missing ; before statement
"$" - $ is not defined
"@" missing name after @
"@.POWER" missing name after @
"@POWER" cannot read property "@"":POWER" from undefined
"val" is not defined
event


(10:54) 49.2 / 18.2 turned zone off

(11:16) 
event.payload = event.payload.split(',')[6].split(':')[1];

works for a text box

(14:36) rad 16.8 / 14.4

So a bit of a dilemna

So there are currently four ways to turn a sonoff on or off, say for my light
1) Using Node-Red by pointing a browser to: http://192.168.1.105:1880/ui
2) Pressing a MQTT Dash app button
3) Manually pressing the button on each unit
4) Point a browser to the IP address of a sonoff and clicking the"Toggle" button

They will each be done by or cause "ON" or "OFF" to be published to MQTT topic  "cmnd/sonoff_3536/POWER". And on being actioned to "stat/sonoff_3536/POWER". If this is done with the "retained" flag set in all four cases then anybody launching the app or going to that website and subscribing to topic "stat/sonoff_3536/POWER" will instantly get the latest sonoff status.

Great write-up
http://www.thesmarthomehookup.com/end-random-ghost-switching-for-good-by-fixing-your-retain-settings-in-tasmota-and-home-assistant/

"switchretain on" using console resulted in:
15:27:04 CMD: switchretain on
15:27:04 MQT: stat/sonoff_3536/RESULT = {"SwitchRetain":"ON"}

"buttonretain on" ..
15:28:13 CMD: buttonretain on
15:28:13 MQT: stat/sonoff_3536/RESULT = {"ButtonRetain":"ON"}

"powerretain on"
15:28:54 CMD: powerretain on
15:28:54 MQT: stat/sonoff_3536/RESULT = {"PowerRetain":"ON"}

(16:22) 16.9 / 17.5 (using the electric fan heater)

Finally trying micro Python
https://docs.micropython.org/en/latest/esp8266/tutorial/intro.html
http://micropython.org/download#esp8266
Flashed to board using NodeMcu PyFlasher (frontend for esptool.py)
Command: esptool.py --port COM8 --baud 115200 --after no_reset write_flash --flash_mode dio 0x00000 C:\Users\kilnageer\Documents\CoderDojo\2018 Reboot\CH Project\NodeMcu\esp8266-20190125-v1.10.bin --erase-all

Worked fine then reset board and used ESPlorer for UART window

MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
>>> 
>> 
help()
help()
Welcome to MicroPython!

For online docs please visit http://docs.micropython.org/en/latest/esp8266/ .
For diagnostic information to include in bug reports execute 'import port_diag'.

Basic WiFi configuration:

import network
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if.scan()                             # Scan for available access points
sta_if.connect("<AP_name>", "<password>") # Connect to an AP
sta_if.isconnected()                      # Check for successful connection
# Change name/password of ESP8266's AP:
ap_if = network.WLAN(network.AP_IF)
ap_if.config(essid="<AP_NAME>", authmode=network.AUTH_WPA_WPA2_PSK, password="<password>")

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-C        -- interrupt a running program
  CTRL-D        -- on a blank line, do a soft reset of the board
  CTRL-E        -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
>>>

Did above commands to connect
import network
import network
>>> 
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
#6 ets_task(4020f4d0, 28, 3fff9e28, 10)
>>> 
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
sta_if = network.WLAN(network.STA_IF); sta_if.active(True)
>>> sta_if.scan() 
sta_if.scan() 
[(b'vodafone-2124', b'\xe8\xab\xfa\xb0\xc4D', 1, -53, 3, 0)]
>>> sta_if.connect("vodafone-2124", PASSWORD )
sta_if.connect("vodafone-2124", PASSWORD )
>>> sta_if.isconnected()
sta_if.isconnected()
True
>>> 
ESP_2871DF_EthernetEC:FA:BC:28:71:DF192.168.1.112

http://micropython.org/webrepl/


(23:17) Two issues have come to light:

1) Some sonoffs drop LAN connection every few minutes (especially Extension Zone MV)
2) They don't restore their retained setting. A bug? Instead they restore the last one set by Node-Red.

So ensure that Node-Red is used to set the sonoffs. Otherwise their settings can change.

I'll investigate more tomorrow.