Heartbeat error ?



  • Hi,

    I have a relay node that don't have any sensors, and therefore don't have communication between the vera and the node. like this 0_1476877480815_upload-2c34fc65-9174-4f19-8dcb-9a2ea935b695

    So I have been playing with heartbeat and I cas see in serial log local on the node that it is transmitted.

    BUT my node in VERA dont update the last update time : Is tyhis how is sopose to be or do I something wrong?

    Here are my code :

    /**
     * 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
     */ 
    
    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    
    // Enable repeater functionality for this node
    // #define MY_REPEATER_FEATURE
    
    #include <SPI.h>
    #include <MySensors.h>
    
    #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 2 // 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
     long double last_heartbeat_time = millis();
     long double HEARTBEAT_TIME = 120000;
    
    
    void before() { 
      for (int sensor=1, pin=RELAY_1; 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() {
    }
    
    void presentation()  
    {   
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Relay", "1.0");
    
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    }
    
    
    void loop() 
    {
      long double temp = (millis() - last_heartbeat_time);
      if (temp > HEARTBEAT_TIME) {
      // If it exceeds the heartbeat time then send a heartbeat
      sendHeartbeat();
      last_heartbeat_time = millis();
      
      #ifdef MY_DEBUG
        Serial.print("Sent heartbeat" );
        Serial.println(temp)
      #endif
    }
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_LIGHT) {
         // Change relay state
         digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
         // Store state in eeprom
         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());
       } 
    }
    

  • Hero Member

    According to the Controller compatibility list Vera does not yet support heartbeat -> https://www.mysensors.org/controller



  • @korttoma
    😢 I did not see that 😢
    Is there any plan for implementing this ?


  • Admin

    You can just send the last state every HEARTBEAT_TIME... should have the same effect.


Log in to reply
 

Suggested Topics

  • 33
  • 5
  • 8
  • 6
  • 2
  • 11

56
Online

11.4k
Users

11.1k
Topics

112.6k
Posts