dmitrif / onvif2mqtt

Translate ONVIF events (from IP Cameras) to MQTT messages.
Other
118 stars 31 forks source link

ADD Support for camera #39

Closed leranp closed 3 years ago

leranp commented 3 years ago

Hi, I have a new camera that I think is publish in a different way , and the event doesn't handle by the onvif2mqtt, when I start onvif2mqtt the onvif2mqtt/camera/motion is "ON" , and when there is a motion detection onvif2mqtt send to the topic (onvif2mqtt/camera/motion) the value "OFF" , but it doesn't change the value after there is no motion. pleas help me this is the log from the camera :

(reply){
   CurrentTime = 2021-03-14 15:00:21
   TerminationTime = 2021-03-14 15:01:21
   NotificationMessage[] =
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/TamperDetector/Tamper"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyTamperDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "IsTamper"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/CellMotionDetector/Motion"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyMotionDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:VideoSource/MotionAlarm"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "Source"
                                 _Value = "V_SRC_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:Device/Trigger/DigitalInput"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "InputToken"
                                 _Value = "DIGIT_INPUT_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "LogicalState"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/TamperDetector/Tamper"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyTamperDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "IsTamper"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/CellMotionDetector/Motion"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyMotionDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:VideoSource/MotionAlarm"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "Source"
                                 _Value = "V_SRC_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:Device/Trigger/DigitalInput"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "InputToken"
                                 _Value = "DIGIT_INPUT_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "LogicalState"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/TamperDetector/Tamper"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyTamperDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "IsTamper"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/CellMotionDetector/Motion"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyMotionDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:VideoSource/MotionAlarm"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "Source"
                                 _Value = "V_SRC_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:Device/Trigger/DigitalInput"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "InputToken"
                                 _Value = "DIGIT_INPUT_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "LogicalState"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/TamperDetector/Tamper"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyTamperDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "IsTamper"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/CellMotionDetector/Motion"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyMotionDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:VideoSource/MotionAlarm"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "Source"
                                 _Value = "V_SRC_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:Device/Trigger/DigitalInput"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:21Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "InputToken"
                                 _Value = "DIGIT_INPUT_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "LogicalState"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/TamperDetector/Tamper"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:20Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyTamperDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "IsTamper"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:RuleEngine/CellMotionDetector/Motion"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:20Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem[] =
                              (SimpleItem){
                                 _Name = "VideoSource"
                                 _Value = "V_SRC_000"
                              },
                              (SimpleItem){
                                 _Name = "Rule"
                                 _Value = "MyMotionDetectorRule"
                              },
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:VideoSource/MotionAlarm"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:20Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "Source"
                                 _Value = "V_SRC_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "State"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
      (NotificationMessageHolderType){
         Topic =
            (Topic){
               value = "tns1:Device/Trigger/DigitalInput"
               _Dialect = "http://www.onvif.org/ver10/tev/topicExpression/Concre                                                                             teSet"
            }
         Message =
            (Message){
               Message =
                  (Message){
                     _UtcTime = "2021-03-14T13:00:20Z"
                     _PropertyOperation = "Initialized"
                     Source =
                        (Source){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "InputToken"
                                 _Value = "DIGIT_INPUT_000"
                              }
                        }
                     Data =
                        (Data){
                           SimpleItem =
                              (SimpleItem){
                                 _Name = "LogicalState"
                                 _Value = "true"
                              }
                        }
                  }
            }
      },
 }

the log from onvif2mqtt:

onvif2mqtt       | {"level":30,"time":1615815275074,"name":"ONVIF/camera","hostname":"192.168.31.27","msg":"CreatePullPointSubscription camera","v":1}
onvif2mqtt       | {"level":20,"time":1615816834006,"name":"MQTT","hostname":"192.168.31.100:1883","msg":"Publishing. {\"topic\":\"onvif2mqtt/camera/motion\",\"value\":\"ON\",\"retain\":true}","v":1}
onvif2mqtt       | {"level":20,"time":1615834504440,"name":"MQTT","hostname":"192.168.31.100:1883","msg":"Publishing. {\"topic\":\"onvif2mqtt/camera/motion\",\"value\":\"OFF\",\"retain\":true}","v":1}
onvif2mqtt       | {"level":20,"time":1615834504478,"name":"MQTT","hostname":"192.168.31.100:1883","msg":"Publishing. {\"topic\":\"onvif2mqtt/camera/motion\",\"value\":\"OFF\",\"retain\":true}","v":1}
onvif2mqtt       | {"level":20,"time":1615834504479,"name":"MQTT","hostname":"192.168.31.100:1883","msg":"Publishing. {\"topic\":\"onvif2mqtt/camera/motion\",\"value\":\"OFF\",\"retain\":true}","v":1}
onvif2mqtt       | {"level":20,"time":1615834504488,"name":"MQTT","hostname":"192.168.31.100:1883","msg":"Publishing. {\"topic\":\"onvif2mqtt/camera/motion\",\"value\":\"OFF\",\"retain\":true}","v":1}
onvif2mqtt       | {"level":20,"time":1615834504489,"name":"MQTT","hostname":"192.168.31.100:1883","msg":"Publishing. {\"topic\":\"onvif2mqtt/camera/motion\",\"value\":\"OFF\",\"retain\":true}","v":1}
onvif2mqtt       | {"level":20,"time":1615834504490,"name":"MQTT","hostname":"192.168.31.100:1883","msg":"Publishing. {\"topic\":\"onvif2mqtt/camera/motion\",\"value\":\"OFF\",\"retain\":true}","v":1}
leranp commented 3 years ago

in the log i can see only the "tns1:RuleEngine/TamperDetector/Tamper" message, he is ignore the rest of the events