Guys, I've changed that configuration and it perfectly works !!!
Now I'm going to automate all the house...
Thanks for all the support and patience.
Guys, I've changed that configuration and it perfectly works !!!
Now I'm going to automate all the house...
Thanks for all the support and patience.
Guys, I'm adding this info to the thread just in case that someone may get this useful.
This is my final sketch:
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik Ekblad
*
* DESCRIPTION
* Example sketch showing how to control physical relays.
* This example will remember relay state after power failure.
* http://www.mysensors.org/build/relay
*/
#include <MySigningNone.h>
#include <MyTransportNRF24.h>
#include <MyTransportRFM69.h>
#include <MyHwATMega328.h>
#include <MySensor.h>
#include <SPI.h>
#define SN "Living Foot Lamp"
#define SV "1.0"
#define NODE_ID 19
#define RELAY_PIN 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define RELAY_CHILD 1
#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
// NRFRF24L01 radio driver (set low transmit power by default)
MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
// Select AtMega328 hardware profile
MyHwATMega328 hw;
// Construct MySensors library
MySensor gw(radio, hw);
MyMessage msg(RELAY_CHILD, V_STATUS);
void setup()
{
// Initialize library and add callback for incoming messages
gw.begin(incomingMessage, NODE_ID);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo(SN, SV);
gw.present(RELAY_CHILD, S_LIGHT);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, RELAY_OFF);
gw.send(msg.set(0));
}
void loop()
{
// Alway process incoming messages whenever possible
gw.process();
}
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_STATUS) {
// Change relay state
digitalWrite(RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
// debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
I'm not finished my board, but here are some pictures showing how I assembled all the pieces
Video: Show how is The Relay is Working
Guys, I'm adding this info to the thread just in case that someone may get this useful.
This is my final sketch:
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik Ekblad
*
* DESCRIPTION
* Example sketch showing how to control physical relays.
* This example will remember relay state after power failure.
* http://www.mysensors.org/build/relay
*/
#include <MySigningNone.h>
#include <MyTransportNRF24.h>
#include <MyTransportRFM69.h>
#include <MyHwATMega328.h>
#include <MySensor.h>
#include <SPI.h>
#define SN "Living Foot Lamp"
#define SV "1.0"
#define NODE_ID 19
#define RELAY_PIN 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define RELAY_CHILD 1
#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
// NRFRF24L01 radio driver (set low transmit power by default)
MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
// Select AtMega328 hardware profile
MyHwATMega328 hw;
// Construct MySensors library
MySensor gw(radio, hw);
MyMessage msg(RELAY_CHILD, V_STATUS);
void setup()
{
// Initialize library and add callback for incoming messages
gw.begin(incomingMessage, NODE_ID);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo(SN, SV);
gw.present(RELAY_CHILD, S_LIGHT);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, RELAY_OFF);
gw.send(msg.set(0));
}
void loop()
{
// Alway process incoming messages whenever possible
gw.process();
}
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_STATUS) {
// Change relay state
digitalWrite(RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
// debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
I'm not finished my board, but here are some pictures showing how I assembled all the pieces
Video: Show how is The Relay is Working
Guys, I've changed that configuration and it perfectly works !!!
Now I'm going to automate all the house...
Thanks for all the support and patience.
Martin, I've added that line and now i can see the sensor as a switch on my HA web interface. The thing now is, when I trigger the switch from OFF to ON, the serial gateway sends the information to the node but the switch come back to OFF state. This is what i'm seeing on logs
NFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:gateway started, id=0, parent=0, distance=0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.4
INFO:homeassistant.components.mysensors:No sketch_name: node 19
INFO:homeassistant.components.mysensors:No sketch_name: node 19
INFO:homeassistant.components.mysensors:No sketch_name: node 19
INFO:homeassistant.components.mysensors:No sketch_name: node 19
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-19-19 s=255,c=3,t=6,pt=0,l=1,sg=0,st=ok:M
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=11,pt=0,l=12,sg=0:Relay Outlet
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=1,c=0,t=3,pt=0,l=0,sg=0:
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=1,c=1,t=2,pt=2,l=2,sg=0:1
INFO:homeassistant.components.mysensors:Adding new devices: <Entity Relay Outlet 19 1: off>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state switch.relay_outlet_19_1=unavailable; friendly_name=Relay Outlet 19 1 @ 2016-06-06T13:53:25.968979-03:00>, entity_id=switch.relay_outlet_19_1>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state group.all_switches=unknown; auto=True, friendly_name=all switches, hidden=True, order=0, entity_id=[] @ 2016-06-06T13:53:25.981643-03:00>, entity_id=group.all_switches>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state group.all_switches=unknown; auto=True, friendly_name=all switches, hidden=True, order=0, entity_id=[] @ 2016-06-06T13:53:25.981643-03:00>, new_state=None, entity_id=group.all_switches>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=None, new_state=<state group.all_switches=unknown; auto=True, friendly_name=all switches, hidden=True, order=0, entity_id=('switch.relay_outlet_19_1',) @ 2016-06-06T13:53:26.018724-03:00>, entity_id=group.all_switches>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state switch.relay_outlet_19_1=unavailable; friendly_name=Relay Outlet 19 1 @ 2016-06-06T13:53:25.968979-03:00>, new_state=<state switch.relay_outlet_19_1=on; V_STATUS=on, battery_level=0, child_id=1, device=/dev/ttyUSB0, friendly_name=Relay Outlet 19 1, node_id=19 @ 2016-06-06T13:53:26.042212-03:00>, entity_id=switch.relay_outlet_19_1>
INFO:homeassistant.core:Bus:Handling <Event state_changed[L]: old_state=<state group.all_switches=unknown; auto=True, friendly_name=all switches, hidden=True, order=0, entity_id=('switch.relay_outlet_19_1',) @ 2016-06-06T13:53:26.018724-03:00>, new_state=<state group.all_switches=on; auto=True, friendly_name=all switches, hidden=True, order=0, entity_id=('switch.relay_outlet_19_1',) @ 2016-06-06T13:53:26.070897-03:00>, entity_id=group.all_switches>
this is what i see when i press the switch from HA web interface
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=homeassistant, service_data=entity_id=switch.relay_outlet_19_1, service=turn_off, service_call_id=3055117168-3>
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: domain=switch, service_data=entity_id=['switch.relay_outlet_19_1'], service=turn_off, service_call_id=3055117168-4>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=3055117168-4>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=3055117168-3>
INFO:homeassistant.components.http:"POST /api/services/homeassistant/turn_off HTTP/1.1" 200 -
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-19-19 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:0
Thanks!
Hi Martin, I've been reading a lot and still no lucky, can't see my node on the HA. Take a look to my sketch and logs. There's something wrong?
Thanks again!
Sketch:
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik Ekblad
*
* DESCRIPTION
* Example sketch showing how to control physical relays.
* This example will remember relay state after power failure.
* http://www.mysensors.org/build/relay
*/
#include <MySigningNone.h>
#include <MyTransportNRF24.h>
#include <MyTransportRFM69.h>
#include <MyHwATMega328.h>
#include <MySensor.h>
#include <SPI.h>
#define SN "Relay Outlet"
#define SV "1.0"
#define NODE_ID 19
#define RELAY_PIN 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define RELAY_CHILD 1
#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
// NRFRF24L01 radio driver (set low transmit power by default)
MyTransportNRF24 radio(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
//MyTransportRFM69 radio;
// Message signing driver (none default)
//MySigningNone signer;
// Select AtMega328 hardware profile
MyHwATMega328 hw;
// Construct MySensors library
MySensor gw(radio, hw);
MyMessage msg(RELAY_CHILD, V_STATUS);
void setup()
{
// Initialize library and add callback for incoming messages
gw.begin(incomingMessage, NODE_ID);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo(SN, SV);
gw.present(RELAY_CHILD, S_LIGHT);
digitalWrite(RELAY_PIN, RELAY_OFF);
pinMode(RELAY_PIN, OUTPUT);
}
void loop()
{
// Alway process incoming messages whenever possible
gw.process();
}
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_STATUS) {
// Change relay state
digitalWrite(RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
//gw.saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
Logs:
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read and forward: 255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0:
WARNING:mysensors.mysensors:Error decoding message from gateway, bad data received:
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-255-255 s=255,c=3,t=8,pt=1,l=1,sg=0,st=bc:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.4
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-19-19 s=255,c=3,t=6,pt=0,l=1,sg=0,st=ok:M
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=11,pt=0,l=12,sg=0:Relay Outlet
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=1,c=0,t=3,pt=0,l=0,sg=0:
WARNING:mysensors.mysensors:child_id 1 already exists in children, cannot add child
Thanks for your quick reply! I've made those changes to the sketch and uploaded again, now logs looks better without any WARNING.
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.4
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-19-19 s=255,c=3,t=6,pt=0,l=1,sg=0,st=ok:M
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=11,pt=0,l=12,sg=0:Relay Outlet
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=1,c=0,t=3,pt=0,l=0,sg=0:
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=1,c=1,t=3,pt=2,l=2,sg=0:0
What's the next step? I'm still not seeing nodes on my web interface... Where it's supposed to be located?
Thanks.
Hi guys.
I am new to mysensors and homeassistant. I've recently finished my gateway and my first relay node for switching lights on/off. Everything looks good, but I can't see my nodes on the HA web interface. What can I be doing wrong?
I've made this for the serial gateway: https://www.mysensors.org/build/serial_gateway
And for the node I've followed this: https://www.mysensors.org/build/relay (same code shown on the video)
this is my configuration.yaml:
homeassistant:
name: Home
latitude: NONE
longitude: NONE
temperature_unit: C
time_zone: UTC
mysensors:
gateways:
- device: '/dev/ttyUSB0'
debug: true
persistence: true
version: '1.5'
optimistic: false
history:
logbook:
discovery:
frontend:
conversation:
updater:
First I've started my homeassistant and I see this logs:
Starting Home-Assistant
INFO:homeassistant.core:Starting Home Assistant (16 threads)
INFO:homeassistant.core:Bus:Handling <Event homeassistant_start[L]>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: domain=homeassistant, service=restart>
INFO:mysensors.mysensors:Trying to connect to /dev/ttyUSB0
INFO:homeassistant.components.http:Starting web interface at http://0.0.0.0:8123
INFO:homeassistant.core:Timer:starting
INFO:mysensors.mysensors:/dev/ttyUSB0 is open...
INFO:mysensors.mysensors:Connected to /dev/ttyUSB0
INFO:netdisco.service:Scanning
WARNING:homeassistant.components.recorder:Found unfinished sessions
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:gateway started, id=0, parent=0, distance=0
then connect my node to the power and I've got this logs
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=15,pt=2,l=2,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=0,t=17,pt=0,l=5,sg=0:1.5.4
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=6,pt=1,l=1,sg=0:0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:send: 0-0-19-19 s=255,c=3,t=6,pt=0,l=1,sg=0,st=ok:M
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=11,pt=0,l=12,sg=0:Relay Outlet
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=255,c=3,t=12,pt=0,l=3,sg=0:1.0
INFO:mysensors.mysensors:n:0 c:0 t:3 s:9 p:read: 19-19-0 s=0,c=0,t=3,pt=0,l=0,sg=0:
WARNING:mysensors.mysensors:child_id 0 already exists in children, cannot add child
after that i don't see any nodes on the web interface.
Thanks for your help and patience.