Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help with mqtt configuration #10

Closed
n0is3r opened this issue Oct 15, 2021 · 21 comments
Closed

help with mqtt configuration #10

n0is3r opened this issue Oct 15, 2021 · 21 comments

Comments

@n0is3r
Copy link

n0is3r commented Oct 15, 2021

hi,
cant add to Mosquitto broker on home assistant,how can i do manualy?
thanks

@kasitoru
Copy link
Owner

kasitoru commented Oct 16, 2021

Examples

Camera:

camera:
    - platform: ffmpeg
      name: mjsxj02hl
      input: -i rtsp://192.168.1.10:554/primary

Humanoid sensor:

binary_sensor:
    - platform: mqtt
      name: humanoid
      device_class: motion
      state_topic: "mjsxj02hl/alarm"
      value_template: "{{ value_json.humanoid }}"
      payload_on: true
      payload_off: false

@n0is3r
Copy link
Author

n0is3r commented Oct 16, 2021

Logger: homeassistant.helpers.template
Source: helpers/template.py:565
First occurred: 19:13:45 (3 occurrences)
Last logged: 19:14:13

Error parsing value: 'value_json' is undefined (value: , template: {{ value_json.humanoid }})
Error parsing value: 'value_json' is undefined (value: humanoid, template: {{ value_json.humanoid }})

@kasitoru
Copy link
Owner

Try it:

value_template: "{{ value_json['humanoid'] }}"

and show the contents of the topic mjsxj02hl/alarm

@attilioscot
Copy link

attilioscot commented Oct 21, 2021

I had configured correctly my sensors as in first comment from @kasitoru: they used to work in version 1.2.4, after upgrading to 1.2.6 they no longer work. I'll try downgrading ASAP to test more.

@kasitoru
Copy link
Owner

kasitoru commented Oct 21, 2021

show the contents of the topic mjsxj02hl/alarm

use MQTT Explorer

and show your current sensor configuration

@attilioscot
Copy link

There was no topic created for me in version 1.2.6: simply going back to version 1.2.4 solved the issue, with no change in configuration

@kasitoru
Copy link
Owner

kasitoru commented Oct 27, 2021

@attilioscot show your configuration for version 1.2.6 and full log

@attilioscot
Copy link

I have to correct myself: the topic is created and messages go trough, but very often updates fail, apparently because of disconnections as in this piece of log. Follows also my configuration, tell me how I can send a full log if needed.

[mqtt][mqtt_periodical]: asprintf() success. [mqtt][mqtt_periodical]: yyjson_mut_write() success. [mqtt][mqtt_send]: Function is called... [mqtt][mqtt_send]: Topic: xiaomicam2/info [mqtt][mqtt_send]: Payload: {"sdk_version":14,"fw_version":"1.2.4","build_time":1626198177,"startup":1635356522,"timestamp":1635357968,"ip_address":"192.168.1.9","total_ram":41467904,"free_ram":2289664,"total_sdmem":1933574144,"free_sdmem":1921122304,"total_configs":393216,"free_configs":163840,"volume_level":70,"media_status":false,"image_url":"http://192.168.1.9/cgi/get_image.cgi"} [mqtt][mqtt_send]: Token: 2 [mqtt][mqtt_send]: MQTTClient_publishMessage() success. [mqtt][mqtt_send]: Function completed. [mqtt][mqtt_periodical]: mqtt_send() success. [mqtt][mqtt_periodical]: Wait 300 seconds until the next sending... [mqtt][mqtt_delivery_callback]: Function is called... [mqtt][mqtt_delivery_callback]: Message with token value 2 delivery confirmed. [mqtt][mqtt_delivery_callback]: Function completed. [mqtt][mqtt_disconnect_callback]: Function is called... [mqtt][mqtt_disconnect_callback]: The connection to the MQTT server was lost! Wait 60 seconds... [mqtt][mqtt_free]: Function is called... [mqtt][mqtt_free]: pthread_cancel(periodical_thread) success. [mqtt][mqtt_free]: MQTTClient_unsubscribe() error! [mqtt][mqtt_free]: MQTTClient_disconnect() success. [mqtt][mqtt_free]: Function completed. [alarm][alarm_state_timeout]: Change motion status: 1 [alarm][alarm_state_timeout]: Change motion status: 0 [alarm][alarm_state_timeout]: Change motion status: 1 [alarm][alarm_state_timeout]: Change motion status: 0

configuration:
`[alarm]
humanoid_sens=250
humanoid_timeout=60
motion_sens=2
motion_lost_exec=
humanoid_detect_exec=
motion_timeout=5
humanoid_lost_exec=
motion_detect_exec=

[audio]
secondary_enable=true
volume=70
primary_enable=true

[general]
led=true

[osd]
oemlogo_y=0
oemlogo_x=2
oemlogo_size=0
datetime_size=0
datetime_x=48
datetime=true
datetime_y=0
enable=false
motion=false
humanoid=false
oemlogo=true

[speaker]
volume=70
type=1

[video]
mirror=true
primary_type=1
gop=1
flip=true
secondary_bitrate=300
secondary_type=2
secondary_enable=true
primary_bitrate=1600
secondary_rcmode=0
primary_rcmode=2
primary_enable=true

[logger]
file=/mnt/mmc/debug.log
level=4

[night]
gray=0
mode=2

[rtsp]
primary_name=primary
port=554
username=
primary_split_vframes=true
secondary_name=secondary
secondary_multicast=false
secondary_split_vframes=true
enable=true
primary_multicast=false
password=

[mqtt]
port=8583
retain=false
server=192.168.1.2
enable=true
username=
password=
qos=1
topic=xiaomicam2
`

@kasitoru
Copy link
Owner

The problem is most likely not in the camera. Perhaps a weak Wi-Fi signal or a problem with the MQTT server. Communication breaks due to external factors.

@TheBisk
Copy link

TheBisk commented Nov 4, 2021

Hi avdeevsv91,
it's been a few days I haven't received any more movement alarms from MQTT. I see in the broker log that the cam is always disconnected due to timeout.

1635977478: New client connected from 192.168.178.117 as MJSXJ02HL (p2, c1, k60, u'User').
1635977568: Client MJSXJ02HL has exceeded timeout, disconnecting.

Even from mqtt explorer I don't see any alarm messages. I tried to restart the device but nothing has changed.

  • platform: mqtt
    name: GiardinoIpCam Human Motion
    device_class: motion
    state_topic: "mjsxj02hl/alarm"
    value_template: "{{ value_json.humanoid }}"
    payload_on: true
    payload_off: false

  • platform: mqtt
    name: GiardinoIpCam Motion
    device_class: motion
    state_topic: "mjsxj02hl/alarm"
    value_template: "{{ value_json.motion }}"
    payload_on: true
    payload_off: false

Any idea on how to fix it?
Tks

@kasitoru
Copy link
Owner

kasitoru commented Nov 4, 2021

@TheBisk, show the camera log

@TheBisk
Copy link

TheBisk commented Nov 5, 2021

how to access the log file?
image

@kasitoru
Copy link
Owner

kasitoru commented Nov 5, 2021

Set filepath /mnt/mmc/log.txt, insert sd cart and reboot you camera.

@TheBisk
Copy link

TheBisk commented Nov 5, 2021

mqtt][mqtt_send]: Topic: mjsxj02hl/alarm
[mqtt][mqtt_send]: Payload: {"motion":true,"humanoid":false,"timestamp":1636115231}
[mjsxj02hl_application][signal_callback]: Function is called...
[mjsxj02hl_application][signal_callback]: local_sdk_indicator_led_option(true, false) success.
[mqtt][mqtt_free]: Function is called...
[mqtt][mqtt_free]: pthread_cancel(periodical_thread) success.
[mqtt][mqtt_send]: MQTTClient_publishMessage() error!
[mqtt][mqtt_send]: Function completed.
[alarm][alarm_state_mqtt]: mqtt_send() error!
[alarm][alarm_state_mqtt]: Function completed.
[alarm][alarm_state_timeout]: alarm_state_mqtt() error!
[mqtt][mqtt_send]: MQTTClient_publishMessage() error!
[mqtt][mqtt_send]: Function completed.
[mqtt][mqtt_periodical]: mqtt_send() error!
[mqtt][mqtt_periodical]: Function completed.
[mqtt][mqtt_message_callback]: Function completed.
[mqtt][mqtt_free]: MQTTClient_unsubscribe() error!
[mqtt][mqtt_free]: MQTTClient_disconnect() success.
[mqtt][mqtt_free]: Function completed.
[mjsxj02hl_application][signal_callback]: mqtt_free(true) error!
[rtsp][rtsp_free]: Function is called...
[rtsp][rtspserver]: Stopping the media session #2...
[mqtt][mqtt_disconnect_callback]: Function is called...
[mqtt][mqtt_disconnect_callback]: The connection to the MQTT server was lost! Wait 60 seconds...
[mqtt][mqtt_free]: Function is called...
[mqtt][mqtt_free]: pthread_cancel(periodical_thread) error!
[mqtt][mqtt_free]: MQTTClient_unsubscribe() error!
[mqtt][mqtt_free]: MQTTClient_disconnect() error!
[mqtt][mqtt_free]: Function completed.
[rtsp][rtspserver]: Stopping the media session #3...
[rtsp][rtspserver]: The RTSP server is stopped.
[rtsp][rtsp_free]: rtspserver_free() success.
[rtsp][rtsp_free]: Function completed.

@kasitoru
Copy link
Owner

kasitoru commented Nov 6, 2021

Need a full log. Use pastebin

@TheBisk
Copy link

TheBisk commented Nov 7, 2021

Here is my log, debbuging errors:
https://pastebin.com/mUf1ZNCi

I see errors for night mode and alarm, no problem for the video stream,
Thanks.

@kasitoru
Copy link
Owner

kasitoru commented Nov 7, 2021

Set logger level to "debug" and try again

@TheBisk
Copy link

TheBisk commented Nov 9, 2021

Set logger level to "debug" and try again

Here you are --> https://pastebin.com/DuyN3RKF

I cannot understand why my binary_sensors humanoid and motion are not working anymore.

Thanks.

@kasitoru
Copy link
Owner

kasitoru commented Nov 9, 2021

@TheBisk There are no errors in the log when sending MQTT messages. Use MQTT Explorer, subscribe to mjsxj02hl/# and check inbox messages.

@TheBisk
Copy link

TheBisk commented Nov 9, 2021

@kasitoru Can you please show a script for getting a screenshot by the cam?

@kasitoru
Copy link
Owner

kasitoru commented Nov 9, 2021

@TheBisk I don't use it, but you can get pictures just by downloading an image at this address http://<camera_ip>/cgi-bin/get_image.cgi

@kasitoru kasitoru closed this as completed Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants