I do not know why these spaces occur, they are not in configuration.yaml, but only in my post here where the code is copied from Arduino IDE.
Here it is again without spaces, and it looks like it’s flashed.
I’m a beginner in Home Assistant.
Will a switch appear in HA States solely on the basis of the configuration.yaml content, or will it be visible only when there is communication to the device?
==============================================================================
Changes in v1.01
- Relay state now stored in EEPROM and will power up with last relay state
==============================================================================
**** USE THIS Firmware for: Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Smart Socket ****
*/
#include <EEPROM.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Ticker.h>
#define BUTTON 0 // (Don't Change for Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Socket)
#define RELAY 12 // (Don't Change for Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Socket)
#define LED 13 // (Don't Change for Original Sonoff, Sonoff SV, Sonoff Touch, Sonoff S20 Socket)
#define MQTT_CLIENT "Sonoff_Living_Room_v1.01p" // mqtt client_id (Must be unique for each Sonoff)
#define MQTT_SERVER "192.168.1.155" // mqtt server
#define MQTT_PORT 1883 // mqtt port
#define MQTT_TOPIC "home/sonoff/living_room/1" // mqtt topic (Must be unique for each Sonoff)
#define MQTT_USER "haadmin" // mqtt user
#define MQTT_PASS "***************" // mqtt password
#define WIFI_SSID "Bielefeldt_Waoo2" // wifi ssid
#define WIFI_PASS "***************" // wifi password
#define VERSION "\n\n------------------ Sonoff Powerpoint v1.01p ------------------"
Only based on configuration.yaml. It does not need to communicate to appear. If the switch flashes 4 times fast, then it has connected to your broker. That’s the point of the status LED. Just copy the configuration.yaml from the github exactly as it is. Your issue is capitalization and syntax. YAML is very picky.
Thank you very much kiethh666 - now I have a breakthrough
I was first challenged because I tried to cut the code from your post into configuration.yaml. As a result, the Home Assistant went down (did not answer).
After some time, I could admit it had something to do with the new code. Only after many reboots, I recognized that the code should be manually entered. There were probably some hidden codes with which the Home Assistant will not accept.
But then I got my successful breakthrough
Now my switch works and I can move on to implement more switches in my configuration.
I’m not familiar with Home Assistant yet, and have trouble getting the smallest details to work, so I’ve created a new thread because my HA is constantly goes down, when i write in configuration.yaml.
Hope I figure out what I’m doing wrong.
Thank you for your great work on implementing Sonoff firmware, it’s wonderfully well done.
@KmanOz thanks for sharing your work! I really appreciate it! I’ve managed to setup two SonOff POW following your guide in github and reading this nearly-600-commented thread. For someone not used to this electronics world is pretty amazing. I write some comments based on my little experience just to encourage other people not to give up when finding troubles:
I had to solder a header in the SonOff
I had to provide an external 3V3 to the SonOff when flashing because I read that powering it with the FTDI is not enough. I used an Arduino UNO for this. I also connected the three GNDs (FTDI, SonOff and Arduino UNO) together.
I spent quite a lot of time with trial-and-error approach flashing the unit. Sorry, I cannot provide a hint for the combination of: when powering the SonOff, when pushing the SonOff button and for how long, and when pressing Ctril+U in the Arduino IDE to compile and upload the code.
I couldn’t see any message from the SonOff sent to the serial console (is this the expected behavior?), so I had no idea if the device was properly flashed. I encourage to do the home-assistant stuff previously and have the HASS frontend so when you finish the flashing process you can switch on and off the device in the frontend and check if the red LED turns on and off.
We love pictures! Two pictures attached: the wiring connections between FTDI, SonOff and Arduino that were ok for me (sorry for the bad quality) and the result in the HASS frontend.
Here are my experiences in flashing as a complete electronics noob:
used FTDI only to power
didn’t solder a header, just plugged the pins and put slight pressure on them to keep contact
used serial console for debugging after flashing
managed to flash two POWs, one S20 and one touch. The touch was a bit problematic since I had to change to ESP8285 for the flash to work properly and grounding the GPI0 without soldering was fiddly
I had so much fun doing it all. Maybe when my regular sonoff’s arrive I’ll actually try and solder some header pins in for a change
Archiving built core (caching) in: C:\Users\WinPC\AppData\Local\Temp\arduino_cache_115109\core\core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_1M64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____f7025fb08a3574e99f1785948801a9c1.a
Sketch uses 440072 bytes (45%) of program storage space. Maximum is 958448 bytes.
Global variables use 44176 bytes (53%) of dynamic memory, leaving 37744 bytes for local variables. Maximum is 81920 bytes.
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
Yes i did, but i am not sure in configuration and where can i find MQTT FINGERPRINT ? I create one user name and password during homeassistant installation port :1883 with script sudo hassbian-config install mosquitto and other one i have in CloudMQTT console and some other i create in CloudMQTT manage users.
#ifdef USE_MQTT_TLS #define MQTT_HOST “m20.cloudmqtt.com” // [MqttHost] #define MQTT_FINGERPRINT “A5 02 FF 13 99 9F 8B 39 8E F1 83 4F 11 23 65 0B 32 36 FC 07” // [MqttFingerprint] #define MQTT_PORT 20123 // [MqttPort] MQTT TLS port #define MQTT_USER “cloudmqttuser” // [MqttUser] Mandatory user #define MQTT_PASS “cloudmqttpassword” // [MqttPassword] Mandatory password #else #define MQTT_HOST “RPi IP adress ?” // [MqttHost] #define MQTT_PORT RPI IP adress ? // [MqttPort] MQTT port (10123 on CloudMQTT) #define MQTT_USER “Managed user in CloudMQTT Console ?” // [MqttUser] Optional user #define MQTT_PASS " Pass" // [MqttPassword] Optional password
Glad to see that Tasmota is straight forward for new users hahaha. Anyway the issue above isn’t causing this issue.
This issue is caused by not pressing and holding the button on the Sonoff BEFORE plugging the USB cable into the FTDI adaptor like blakadder said. As for the rest of your issues I think there is now a topic that covers Tasmota (or whatever the firmware you are using is) issues. You may have more luck getting answers in there. Good luck.
Note to any others using this version, I find use in adding these 2 lines into the “void setup() {” block. This uses the nice human-readable name for the DHCP lease & the OTA line in your Arduino IDE. Makes identifying them much easier
void setup() {
...
WiFi.hostname(MQTT_CLIENT); // Set DHCP hostname
ArduinoOTA.setHostname(MQTT_CLIENT); // Set OTA IDE name
...