Detect missing/unresponsive sensor.



  • I have just got up and running with the serial gateway and one motion sensor. Domoticz picked everything up first time which was a nice surprise.

    I have noticed that the sensor code is set to wake and send out a status every 2 minutes and I can see the 1's and 0's in the serial monitor. Domoticz only reports the last sensor activation and the logs just show each on and subsequent off. It does not show each 0 for every 2 minutes of inactivity.

    I am thinking along the lines of jamming detection - Is there a way for Domoticz to know if the sensor is still reporting without having to wait for the next positive activation?



  • @grumpazoid I get this a lot here. In MyController I can see the data each time it is sent. It seems that you are only seeing data when a change occurs. Perhaps there is a setting somewhere? I don't use Domoticz.

    I notice that my sensors nodes can just stop sending data. Sometimes it stops until I reboot the node, sometimes it just seems to not send for a period of time ranging from minutes to many hours and then starts sending again all by itself.

    I have tried sending heartbeat at regular intervals and then replaced heartbeat by having the node just send its status reglardless of whether or not it has changed. Neither of these approaches have worked for me. So far I have failed to get any further than this.

    If you want to detect jamming, then can I suggest a jam detection node dedicated to this task. There is more than one approach to jamming detection.

    If you are using the nrf24 modules, they are capable of frequency hopping which gives resilience to jamming to a large degree, but I don't believe this function is supported by my sensors.



  • Hi, @grumpazoid !
    Possibly sendHeartbeat(); could help you, but currently domoticz doesn't work correctly with it (without sending data).
    I've opened an issue on github, at latest beta gizmocuz make a fix, but as i tested - heartbeat will update last seen time only in devices, not in hardware. - But that if you don't send sensor data, but you are. So try it, but remeber it is beta...
    Also check last seen in hardware, not in devices. They may differ.
    You may create additional switch, and send opposite bool each time (1-0-1-0-1-0), if you want to do some scripting...
    Or just change to a switch type and create dummy alert dvice and update it via script (if switch is 1, then activate alert, and do not deactivate on switch 0)



  • Thanks for the above comments. This has given me some things to look into, especially the heartbeat command.

    I am wondering if MQTT could help. (I have no experience with this yet). From what I have seen MQTT can send out a LWT command if a device is not heard from.



  • Simply change your log. levels.
    If sensor is in idle state - send log.1 to Domoticz - Last Seen will be updated with each log 1 received.
    When motion detected - send log.0 - first log.0 received will trigger your action and change Last Seen time too.
    If you want detect, if sensor hags in triggered state, you can measure time interval for log 0 by LUA or DzVents script.
    If too long - take some action.

    By the way - it is problem MySesnsors part in Domoticz.
    When I am sending switch status from ESPeasy by JSON call, Last Seen time is updated with each
    received value. ON or OFF -both.


  • Mod

    Earlier discussion on the same topic, where we found the root cause: https://forum.mysensors.org/post/29007
    Seems like it never got fixed though.



  • Quick look at Domoticz code
    MySensorsBase.cpp

    void MySensorsBase::UpdateSwitch(const _eSetType vType, const unsigned char Idx, const int SubUnit, const bool bOn, const double Level, const std::string &defaultname, const int BatLevel)
    {
    .
    .
    .
    .
    .
    .
    
    	if (!result.empty())
    	{
    		if (
    			(((vType != V_TRIPPED) || (!bOn))) &&
    			((vType != V_SCENE_OFF) && (vType != V_SCENE_ON))
    			)
    		{
    			//check if we have a change, if not do not update it
    			int nvalue = atoi(result[0][1].c_str());
    			if ((!bOn) && (nvalue == 0))
    				return;
    			if ((bOn && (nvalue != 0)))
    			{
    				//Check Level
    				int slevel = atoi(result[0][2].c_str());
    				if (slevel == level)
    					return;
    			}
    		}
    	}
    

    //check if we have a change, if not do not update it

    It says all :o(
    But interesting is, that for Log 1 value of switch it updates allways.



  • @kimot Thanks for this. So maybe I could comment out the if statements and then it should always update?

    Can I just edit MySensorsBase.cpp and reboot?


  • Mod

    @grumpazoid no you'll need to recompile Domoticz



  • @mfalkvidd ok thanks....



  • I have just added in the code to send battery info. Once again, domoticz only updates when the sensor is activated.

    Edit: I have managed to get the battery updating as required by creating it's own child id. this now shows as a separate sensor in the Domoticz Utility section. It updates as per the sleep setting.

    So for this node I currently have:
    Motion ---- last seen = last activation
    Battery ---- last seen = every 2 minutes.



  • Again some Domoticz code - for update battery level - it is blocked by default:

    void MySensorsBase::UpdateNodeBatteryLevel(const int nodeID, const int Level)
    {
    	std::map<int, _tMySensorNode>::iterator ittNode = m_nodes.find(nodeID);
    	if (ittNode == m_nodes.end())
    		return; //Not found
    	_tMySensorNode *pNode = &ittNode->second;
    	for (auto & itt : pNode->m_childs)
    	{
    		itt.hasBattery = true;
    		itt.batValue = Level;
    
    		//Uncomment the below to for a sensor update
    /*
    		for (const auto & itt2 : itt->values)
    		{
    			if (itt2.second.bValidValue)
    			{
    				_eSetType vType = itt2.first;
    				SendSensor2Domoticz(pNode, &itt, vType);
    			}
    		}
    */
    	}
    }
    

    notice - //Uncomment the below to for a sensor update


Log in to reply
 

Suggested Topics

  • 5
  • 5
  • 2
  • 5
  • 4
  • 4

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts