Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
S

stephenmhall

@stephenmhall
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
71
Topics
10
Shares
0
Groups
0
Followers
2
Following
1

Posts

Recent Best Controversial

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    Hi Anthony.

    Funnily enough I went from the MAX system to a Honeywell Evo system and Domoticz as I have elderly parents and could not risk the times the max just forgot about all its radiators and either left the heating off or on all day.

    Had the Evo for maybe a year now with no problems. The only thing I miss with the evo is notification as to when the heating is actually on. And being able to work on my code as I did enjoy writing it.

    If you need any help with the code just ask, although it has been a while since I looked at it :)

    Stephen

    My Project

  • ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my
    S stephenmhall

    Switches working well but I can't get Temperature to update on a device.

    When switching on a sonoff locally it sends

    mygateway1-in/20/10/1/1/2/1
    

    to the MQTT broker, which immediately causes the switch on the device in Vera to show on, this is passed back out and is sent back to the sonoff.

    However I cannot get a temperature device to update. I send

    mygateway1-in/50/1/1/0/0/20.70
    

    to the Broker but get no change. I can send an html command to update the temp fine.

    here is the Vera device parameters.
    alt text

    I have tried sending to the in and the out topic just to be sure.

    Does anyone have a log from an actual temp node showing the message passed to the gateway just in case someting is not right with my message?

    Also is there a way to monitor the serial messages passed into the Vera from the gateway to check the messages are passing?

    Development

  • ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my
    S stephenmhall

    Would it not need to be added to the Vera as another gateway? I only have a serial gateway on the vera at the moment, I seem to remember I had problems the last time I tried to upgrade to an esp8266 ethernet Gateway and had to go back to the old serial one.

    Mysensor plugin is reporting version 1.5 lib 2.0.0

    Development

  • ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my
    S stephenmhall

    @Efflon I don't think it would, I'm assuming your Home Assistant controller is telling the sonoff to switch using MQTT with your config code

    mysensors:
      gateways:
        - device: mqtt
          persistence_file: '/home/homeassistant/.homeassistant/sonoff.json'
          topic_in_prefix: 'sonoff-out'
          topic_out_prefix: 'sonoff-in'
      debug: false
      optimistic: false
      persistence: true
      retain: true
      version: 2.0
    

    The problem is the Vera controller does not speak MQTT at all, there is a plugin to send device statuses out to a Broker but it's not two way. So all you could do is send the fact that the switch is on or off, but not change it.

    This gets round that by sending out a MySensors message which is then converted into MQTT to switch the Sonoff. so the Vera does not need to know about MQTT and the Sonoff units do not need to know about MySensors.

    Development

  • ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my
    S stephenmhall

    Broker is running on my Synology Diskstation, keeps it all in house as it were. The HA bridge is just there to allow Alexa to control Vera devices.

    Development

  • ESP8266 MQTT gateway + sonoff_MQTT code + vera + HA_Bridge + Alexa, oh my
    S stephenmhall

    Hi guys, I have been playing with a sonoff using MQTT and a Mosquitto server on my Synology diskstation.

    But could not see a way to get control of the sonoff on my vera (with Mysensors) as it does not support MQTT.

    I started to play with the ESP8266 MQTT gateway, the gateway has an NRF radio but is Not connected to the vera as an actual gateway.

    (I just opened a second page on Mysensors to check something and saw Efflon posted a MQTT Sonoff post but his uses home assistant which supports MQTT so I think mine is different enough to keep going)

    Ok so, here is the working chain:

    • "Alexa switch on mains plug 1"

    • Alexa talks to HA Bridge (also running on my Synology) where mains plug 1 is the friendly name of Vera virtual switch device no 181 id 20;10 parent 3

    • HA Bridge talks to Vera in html to switch on the Virtual switch with id 20;10 (I have a 433Txnode with id 20 and 6 switches) with parent id 3(Mysensors plugin)

    • Message then goes out the Mysensors serial gateway and is broadcast over NRF (20/10/1/1/2 1)

    • The ESP8266_MQTT_gateway picks up the message on NRF and sends it on to the MQTT broker (mygateway1-out/20/10/1/1/2 with message 1)

    • The SONOFF unit is subscribed to the broker and picks up the message and switches on.

    if you press the button on the sonoff it works in reverse as far as Vera, sending a message to mygateway1-in/20/10/1/1/2 0 or 1 switching the state of the virtual switch.

    The ESP8266 MQTT gateway code was unchanged.

    Sonoff MQTT code from esp8266.com

    The only change was to the topic name

    /*
    
     It connects to an MQTT server then:
      - on 0 switches off relay
      - on 1 switches on relay
      - on 2 switches the state of the relay
    
      - sends 0 on off relay
      - sends 1 on on relay
    
     It will reconnect to the server if the connection is lost using a blocking
     reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to
     achieve the same result without blocking the main loop.
    
     The current state is stored in EEPROM and restored on bootup
    
    */
    
    #include <ESP8266WiFi.h>
    #include <PubSubClient.h>
    #include <Bounce2.h>
    #include <EEPROM.h>
    
    
    const char* ssid = "ssid";
    const char* password = "password";
    const char* mqtt_server = "broker IP address";
    
    WiFiClient espClient;
    PubSubClient client(espClient);
    long lastMsg = 0;
    char msg[50];
    int value = 0;
    
    //const char* outTopic = "Sonoff1out";
    const char* outTopic = "mygateway1-in/20/10/1/1/2";
    //const char* inTopic = "Sonoff1in";
    const char* inTopic = "mygateway1-out/20/10/1/1/2";
    
    int relay_pin = 12;
    int button_pin = 0;
    bool relayState = LOW;
    
    // Instantiate a Bounce object :
    Bounce debouncer = Bounce(); 
    
    
    void setup_wifi() {
    
      delay(10);
      // We start by connecting to a WiFi network
      Serial.println();
      Serial.print("Connecting to ");
      Serial.println(ssid);
    
      WiFi.begin(ssid, password);
    
      while (WiFi.status() != WL_CONNECTED) {
        extButton();
        for(int i = 0; i<500; i++){
          extButton();
          delay(1);
        }
        Serial.print(".");
      }
      digitalWrite(13, LOW);
      delay(500);
      digitalWrite(13, HIGH);
      delay(500);
      digitalWrite(13, LOW);
      delay(500);
      digitalWrite(13, HIGH);
      Serial.println("");
      Serial.println("WiFi connected");
      Serial.println("IP address: ");
      Serial.println(WiFi.localIP());
    }
    
    void callback(char* topic, byte* payload, unsigned int length) {
      Serial.print("Message arrived [");
      Serial.print(topic);
      Serial.print("] ");
      for (int i = 0; i < length; i++) {
        Serial.print((char)payload[i]);
      }
      Serial.println();
    
      // Switch on the LED if an 1 was received as first character
      if ((char)payload[0] == '0') {
        digitalWrite(relay_pin, LOW);   // Turn the LED on (Note that LOW is the voltage level
        Serial.println("relay_pin -> LOW");
        relayState = LOW;
        EEPROM.write(0, relayState);    // Write state to EEPROM
        EEPROM.commit();
      } else if ((char)payload[0] == '1') {
        digitalWrite(relay_pin, HIGH);  // Turn the LED off by making the voltage HIGH
        Serial.println("relay_pin -> HIGH");
        relayState = HIGH;
        EEPROM.write(0, relayState);    // Write state to EEPROM
        EEPROM.commit();
      } else if ((char)payload[0] == '2') {
        relayState = !relayState;
        digitalWrite(relay_pin, relayState);  // Turn the LED off by making the voltage HIGH
        Serial.print("relay_pin -> switched to ");
        Serial.println(relayState); 
        EEPROM.write(0, relayState);    // Write state to EEPROM
        EEPROM.commit();
      }
    }
    
    void reconnect() {
      // Loop until we're reconnected
      while (!client.connected()) {
        Serial.print("Attempting MQTT connection...");
        // Attempt to connect
        if (client.connect("ESP8266Client")) {
          Serial.println("connected");
          // Once connected, publish an announcement...
          client.publish(outTopic, "Sonoff1 booted");
          // ... and resubscribe
          client.subscribe(inTopic);
        } else {
          Serial.print("failed, rc=");
          Serial.print(client.state());
          Serial.println(" try again in 5 seconds");
          // Wait 5 seconds before retrying
          for(int i = 0; i<5000; i++){
            extButton();
            delay(1);
          }
        }
      }
    }
    
    void extButton() {
      debouncer.update();
       
       // Call code if Bounce fell (transition from HIGH to LOW) :
       if ( debouncer.fell() ) {
         Serial.println("Debouncer fell");
         // Toggle relay state :
         relayState = !relayState;
         digitalWrite(relay_pin,relayState);
         EEPROM.write(0, relayState);    // Write state to EEPROM
         if (relayState == 1){
          client.publish(outTopic, "1");
         }
         else if (relayState == 0){
          client.publish(outTopic, "0");
         }
       }
    }
    
    void setup() {
      EEPROM.begin(512);              // Begin eeprom to store on/off state
      pinMode(relay_pin, OUTPUT);     // Initialize the relay pin as an output
      pinMode(button_pin, INPUT);     // Initialize the relay pin as an output
      pinMode(13, OUTPUT);
      relayState = EEPROM.read(0);
      digitalWrite(relay_pin,relayState);
      
      debouncer.attach(button_pin);   // Use the bounce2 library to debounce the built in button
      debouncer.interval(50);         // Input must be low for 50 ms
      
      digitalWrite(13, LOW);          // Blink to indicate setup
      delay(500);
      digitalWrite(13, HIGH);
      delay(500);
      
      Serial.begin(115200);
      setup_wifi();                   // Connect to wifi 
      client.setServer(mqtt_server, 1883);
      client.setCallback(callback);
    }
    
    void loop() {
    
      if (!client.connected()) {
        reconnect();
      }
      client.loop();
      extButton();
    }
    
    //- See more at: http://www.esp8266.com/viewtopic.php?f=29&t=8746#sthash.vhv33y8Q.dpuf
    

    You don't need to add any extra gateways to Vera, you just add Virtual Switches and program each sonoff (or any other ESP8266) with the different Broker topics needed.

    Development

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    if you need any help with my software let me know, I have swapped to a Honywell system myself so no longer use it but if I can help I will.

    My Project

  • 💬 Building a MQTT Gateway
    S stephenmhall

    Not sure if you want to leave the GPS on there unless that isn't your house with the double hot tub in tha back garden :)

    Announcements

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    Damn, just weeks after I changed to a Honeywell system. Talk about bad timing.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    As far as Cube to valves and valves to cube comms, I think it must be bi-directional as if you change anything on the cube app it happens pretty much instantly. How the cube and valves communicate could be magic for all I know :) they are on the 868Mhz band but what the protocol is I don't know.

    I recently read about a company in Germany called busware.de that makes a Raspberry interface card that has firmware that speaks MAX protocol, I have sent them an email looking to confirm this but not heard anything back yet. If I could cut the Cube out of my system I would be very happy as it is the least reliable part, it seems to factory reset itself every couple of months.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    What I do is only supply heat if valve is open more than 80% or more than 2 valves open 60% so heat shuts off at about 21.9 if you are looking for 22, then the residual heat in the radiator takes temp to about 22.2 before the room starts to slowly cool over the next hour or so down to 21.7 when the valve opens up enough to bring the heat back on.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    Never seen that before, reading the instructions it looks like it switches the boiler on using a daily timer function like the room heating and and a thermostat temperature, possibly if it switches on if any of the rooms are cold that would work. Not saying mine is better but it monitors the valves and gives you heat on demand when any of the radiators call for it.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    @twisted I have added a text file to explain the variables. As for not turning the heating off, not sure, remember that normally the Max system will gradually close the valves on the radiators as the temp goes over the requested temp, you will normally get a half degree or so higher. if it never shuts off I don't understand that it just sends the same vera command with a 1 or a 0.

    link to variables file on Git.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    I have now changed the folder layout on github to make installing easier, also updated some of the files to hopefully stop the error on first run.

    I tried on a blank Raspberry and it all seemed to work ok.

    Give the README instructions a once over and see how it goes.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    For @simrob problem.

    I think the problem is in the database, and my code of course, With the way I developed it over time I think I added features later that cause a problem with a fresh install because It asks for the room names before it creates them. Where my database already had room names populated before I got to that point.
    Could you install "DB Browser for SQLite" and have a look at the heating.db file that was created. Under brows data there should be a rooms table like mine.

    "4" "Living Room" "1051D6"
    "5" "Dining-Extension" "106FD5"
    "2" "Bathroom" "1051DA"
    "3" "Bedroom 1" "116B63"
    "1" "Bedroom 2" "1163A5"

    If it is empty possibly just adding one record with the correct name and a random GroupID might be enough to get it past the point where it fails so it can fully populate the table. Also I think you must be using an older version as your line numbers don't quite match what I have. Try downloading the vera Virtual Thermostats branch and see if that helps, not saying it will but that will become the main branch when I sync it up.
    I will look at getting in installed again on a blank Pi so I can test and fix this properly. But hopefully putting a line of data in the DB rooms table will get you past the problem.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    Ok after faffing about for ages I ended up just moving your replace quote code into the database file, keeps it out of the way and seems to work ok if I simulate a room with a quote in it and without.

    It is happy saving names with a quote in to the DB it is just searching after that needs it doubled. Something else learned.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    kk cheers, I wonder why it is needing 2 quotes? I will have a better look.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    LOL me either maybe you cant. You could save it to google drive or dropbox and post a link i think.

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    grrr, can you send me a copy of your database? I am wondering if it set the room name before the other changes if there is something extra in there.

    And just to check, you are replacing one ' (quote) with two of them?

    My Project

  • Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
    S stephenmhall

    Another tiny update to fix a problem if any of the temperatures went over 25.5 and buy tiny I mean one extra character of code in a binary format string. yesh.

    My Project
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular