@mfalkvidd wow, thank you for your help! I totally misunderstood the radio scenario.
I uploaded my "Gateway + Relay Actuator" sketch and updated the radio section as you suggested. We are connected! I can ping the node.
Now my challenge is getting connected to Home Assistant on my Pi. I'm thinking I need to do some permissions work within HA/Pi.
Thank you!
SKETCH
// Enable debug prints to serial monitor
#define MY_DEBUG
// Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
#define MY_BAUD_RATE 9600
// Enables and select radio type (if attached)
//#define MY_RADIO_RF24
//#define MY_RADIO_RFM69
//#define MY_RADIO_RFM95
#define MY_GATEWAY_ESP8266
#define MY_WIFI_SSID "SSID"
#define MY_WIFI_PASSWORD "Pass"
// Enable UDP communication
//#define MY_USE_UDP // If using UDP you need to set MY_CONTROLLER_IP_ADDRESS or MY_CONTROLLER_URL_ADDRESS below
// Set the hostname for the WiFi Client. This is the hostname
// it will pass to the DHCP server if not static.
#define MY_HOSTNAME "MySensors_Gateway2"
// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
#define MY_IP_ADDRESS 10,0,0,171
// If using static ip you can define Gateway and Subnet address as well
#define MY_IP_GATEWAY_ADDRESS 10,0,0,1
#define MY_IP_SUBNET_ADDRESS 255,255,255,0
// The port to keep open on node server mode
#define MY_PORT 5003
// How many clients should be able to connect to this gateway (default 1)
#define MY_GATEWAY_MAX_CLIENTS 2
#define MY_NODE_ID 1
#include <MySensors.h>
#define RELAY_PIN 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 1 // Total number of attached relays
#define RELAY_ON 1 // GPIO value to write to turn on attached relay
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
void before()
{
for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
}
}
void setup()
{
// Setup locally attached sensors
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Relay", "1.0");
for (int sensor=1, pin=RELAY_PIN; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
// Register all sensors to gw (they will be created as child devices)
present(sensor, S_BINARY);
}
}
void loop()
{
// Send locally attached sensors data here
}
void receive(const MyMessage &message)
{
// We only expect one type of message from controller. But we better check anyway.
if (message.getType()==V_STATUS) {
// Change relay state
digitalWrite(message.getSensor()-1+RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
saveState(message.getSensor(), message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.getSensor());
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
SERIAL MONITOR
MCO:BGN:INIT GW,CP=R-NGE---,FQ=80,REL=255,VER=2.3.2
09:20:06.194 -> 126 MCO:BGN:BFR
09:20:06.267 -> scandone
09:20:07.256 -> 1203 GWT:TIN:CONNECTING...
09:20:08.281 -> 2232 GWT:TIN:CONNECTING...
09:20:09.100 -> scandone
09:20:10.052 -> state: 0 -> 2 (b0)
09:20:10.052 -> 3987 GWT:TIN:CONNECTING...
09:20:10.086 -> state: 2 -> 3 (0)
09:20:10.121 -> state: 3 -> 5 (10)
09:20:10.121 -> add 0
09:20:10.155 -> aid 13
09:20:10.155 -> cnt
09:20:10.155 ->
09:20:10.155 -> connected with SSID, channel 6
09:20:10.189 -> ip:10.0.0.171,mask:255.255.255.0,gw:10.0.0.1
09:20:10.223 -> ip:10.0.0.171,mask:255.255.255.0,gw:10.0.0.1
09:20:10.291 -> 4220 GWT:TIN:IP: 10.0.0.171
09:20:10.324 -> 4249 MCO:BGN:STP
09:20:10.324 -> 4267 MCO:REG:NOT NEEDED
09:20:10.358 -> 4292 MCO:BGN:INIT OK,TSP=NA
09:20:20.092 -> pm open,type:2 0
09:20:47.941 -> 41822 GWT:TSA:C=0,CONNECTED
09:20:47.975 -> 41866 GWT:RFC:C=0,MSG=255;255;3;0;20;
09:20:58.061 -> 51953 GWT:RFC:C=0,MSG=0;255;3;0;2;
09:21:08.201 -> 62090 GWT:RFC:C=0,MSG=0;255;3;0;2;
HOME ASSISTANT CONFIGURATION.YAML
mysensors:
gateways:
- device: '10.0.0.171'
persistence_file: '/home/pi/homeassistant/mysensors/mysensors.json'
tcp_port: 5003
version: '2.0'
HOME ASSISTANT LOGS
2020-05-26 09:20:47 WARNING (SyncWorker_6) [mysensors.persistence] File does not exist or is not readable: /home/pi/homeassistant/mysensors/mysensors.json
2020-05-26 09:20:47 WARNING (SyncWorker_6) [mysensors.persistence] Trying backup file: /home/pi/homeassistant/mysensors/mysensors.json.bak
2020-05-26 09:20:47 WARNING (SyncWorker_6) [mysensors.persistence] File does not exist or is not readable: /home/pi/homeassistant/mysensors/mysensors.json.bak
2020-05-26 09:20:47 WARNING (SyncWorker_6) [mysensors.persistence] Failed to load sensors from file: /home/pi/homeassistant/mysensors/mysensors.json
2020-05-26 09:20:47 ERROR (SyncWorker_2) [mysensors.persistence] Permission denied when writing to /home/pi/homeassistant/mysensors/mysensors.json