I’ve begun integrating the solar pump into the home automation system running in my house (Home-Assistant) using the MySensors platform. The goal is to be able to control the pump via Home-Assistant, and have Home-Assistant automatically water the garden when needed.
So far, I’ve setup a MySensors Gateway, connected it to my Home-Assistant instance, and created a relay switch to turn off/on the pump wirelessly. If this is something you’re interested in doing yourself, here are the pages that I referenced to accomplish this:
- Setup MySensors Gateway: https://www.mysensors.org/build/raspberry
- Connecting MySensors Gateway to Home-Assistant: https://home-assistant.io/components/mysensors/
- Build MySensors Relay: https://www.mysensors.org/build/relay
One big hiccup that I ran into came when I expected the relay sensor to appear in Home-Assistant as a new entity. In order for that to happen, the relay needs to send its initial values to the gateway, which in turn sends this to Home-Assistant. The example Arduino sketch does not do this, so I had to add code to present the initial values in the “loop” function. Here are the lines that I added to the sketch to get it working:
#define CHILD_ID1 1
#define CHILD_ID2 2
bool state = false;
bool initialValueSent = false;
void loop()
{
if (!initialValueSent) {
Serial.println("Sending initial value");
send(msg1.set(state?RELAY_ON:RELAY_OFF));
send(msg2.set(state?RELAY_ON:RELAY_OFF));
Serial.println("Requesting initial value from controller");
request(CHILD_ID1, V_STATUS);
request(CHILD_ID2, V_STATUS);
//wait(2000, C_SET, V_STATUS);
}
}
void receive(const MyMessage &message)
{
if (message.type==V_STATUS) {
...
if (!initialValueSent) {
initialValueSent = true;
}
}Here is the relay sensor itself (Please excuse the shoddy soldering!):


Presentation of Relay in Home-Assistant:
