Updated Tips (markdown)

Michael Ingraham 2019-09-19 10:54:24 -04:00
parent ab4d7e7bac
commit f9a5776587
1 changed files with 8 additions and 29 deletions

37
Tips.md

@ -3,49 +3,28 @@
- [**Yeggi**](https://www.yeggi.com/q/sonoff/)
## Available Characters for HOSTNAME
vvvv RFC952 vvvv
ASSUMPTIONS
1. A "name" (Net, Host, Gateway, or Domain name) is a text string up
to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus
sign (-), and period (.). Note that periods are only allowed when
they serve to delimit components of "domain style names". (See
RFC-921, "Domain Name System Implementation Schedule", for
background). No blank or space characters are permitted as part of a
name. No distinction is made between upper and lower case. The first
character must be an alpha character. The last character must not be
a minus sign or period. A host which serves as a GATEWAY should have
"-GATEWAY" or "-GW" as part of its name. Hosts which do not serve as
Internet gateways should not use "-GATEWAY" and "-GW" as part of
their names. A host which is a TAC should have "-TAC" as the last
part of its host name, if it is a DoD host. Single character names
or nicknames are not allowed.
^^^^ RFC952 ^^^^
- 24 chars max
- only a..z A..Z 0..9 '-'
- no '-' as last char
## Topic, GroupTopic and FallBack Topic
**RFC952**
> ASSUMPTIONS
> 1. A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-), and period (.). Note that periods are only allowed when they serve to delimit components of "domain style names". (See RFC-921, "Domain Name System Implementation Schedule", for background). No blank or space characters are permitted as part of a name. No distinction is made between upper and lower case. The first character must be an alpha character. The last character must not be a minus sign or period. A host which serves as a GATEWAY should have "-GATEWAY" or "-GW" as part of its name. Hosts which do not serve as Internet gateways should not use "-GATEWAY" and "-GW" as part of their names. A host which is a TAC should have "-TAC" as the last part of its host name, if it is a DoD host. Single character names or nicknames are not allowed.
## Topic, GroupTopic, and FallBack Topic
Initially I had one MQTT configurable topic planned called TOPIC but soon found out that when two sonoffs come online with the same topic this would be a challenge at least...
I then introduced a unique, non-configurable topic which I call fallback topic that allows me to always change the MQTT configurable topic to a new unique topic. This fallback topic is just what it is meant to be: A FALLBACK TOPIC in case of emergency.
All MQTT status messages will be sent using the configurable TOPIC which should be made unique by the user. It might be called bedroom but it could also have been called titanic10 as long as the user knows what it is and where to find it.
Having two sonoffs with the same topic allowed for MQTT commands to be sent once to make them act in sono. That inspired me to add a third topic to subscribe to which I call GROUPTOPIC. Sonoffs with the same GROUPTOPIC will react to the same MQTT command. I use it to update firmware to all my sonoffs using separate groups for plain sonoff, pow sonoffs and th sonoffs.
Having two sonoffs with the same topic allowed for MQTT commands to be sent once to make them act in conjunction. That inspired me to add a third topic to subscribe to which I call GROUPTOPIC. Sonoffs with the same GROUPTOPIC will react to the same MQTT command. I use it to update firmware to all my sonoffs using separate groups for plain sonoff, pow sonoffs and th sonoffs.
BTW changing TOPIC can be done online using the fallback topic and is only needed once. There is no need to change user_config.h all the time, as many users seem to think they have to do with any new release. All changes are stored in flash and I make a lot of effort to keep these changes available between versions.
## For Flash afficionados
## Flash Memory Considerations
- To stop saving parameter changes to Flash or Spiffs use command ```SaveData off```.
- To stop saving power changes only to Flash or Spiffs use command ```SetOption0 off```. This will disable the relay from returning to the same state after power on UNLESS you use the MQTT retain flag in which case the MQTT broker will send the last known MQTT state on restart or power on. The command ```ButtonRetain on``` will configure the button to send a MQTT command with Topic and the MQTT retain flag set.
## Debugging
- For debugging purposes you can use Level 4 logging to the `WebLog`, `SerialLog`, or remote [`SysLog`](https://www.sigmdel.ca/michel/ha/rpi/syslog_en.html). For the serial interface and the Arduino IDE set to 115200 baud (19200 for Sonoff Dual) and both NL & CR.
- Debugging the Sonoff Pow is a bit tricky as the serial interface has a **direct connection to one of the AC power lines**. I designed below schematic using two opto couplers seperating the AC connection on the **left** from the low voltage connection on the **right** allowing for serial control at 115200 baud and uploading of firmware up to 57600 baud while AC is connected.
<img alt="OptoSerial" src="https://github.com/arendst/arendst.github.io/blob/master/media/OptoSerial.jpg" />
- To aid in finding the IP address of sonoff the network name will be ```<MQTT_TOPIC>-<last 4 decimal chars of MAC address>```. So the default name is ```sonoff-1234```. Another option is MQTT command ```Status 5```.