Android IP Webcam as a camera plus sensors!

I know the motion entity id.

But it stays off all time, even when I dance in front of the camera (no trigger in hass)

You could use curl on the command line (or Chrome inspector when viewing the camera web interfaces sensor graph) to debug the camera sensors.json output to make sure the sensors are active and reporting data and the sensor you are targeting has a value.

Command line debugging with curl

curl http://IP.ADDRESS:8080/sensors.json?sense=motion_event ; echo

Should output (or similar):

{"motion_event":{"unit":"","data":[[1485567814861,[1.0]],[1485568044149,[0.0]]]}}

Command line debugging with watch + curl

watch -d -n1 curl "http://IP.ADDRESS:8080/sensors.json?sense=motion_event"

Should output similar to the example above, but also run the command every 1 second (-n1) and display the output over top of the previous output, highlighting changes in the terminal.

Curl inside a while loop

while true ; do curl "http://IP.ADDRESS:8080/sensors.json?sense=motion_event" ; echo ^M ; sleep 1s ; done

The echo command in this line should echo a newline character since the curl output doesn’t. You may need to type ctrl+v<enter> rather than copying my ‘^M’ above.

If you are seeing no output or an error from the sensors.json via these commands, you may not have enabled the sensor collection in the IP Webcam app.

Debugging from Chrome/Firefox inspector

Load the IP Webcam web interface in your browser. http://IP.ADDRESS:8080/. Click Open sensor graph:

A new window should open with a chart and lines moving across it and a bunch of checkboxes for various sensors that you enabled from the app settings in the bottom left. Make sure the chart is moving and then go walk around in front of your camera, turn on/off lights around it, etc. and watch the lines in the chart for the Motion indicators.

To get similar output as the Curl commands above, open Chrome/Firefox inspector/developer tools and go to the Network tab. The entries will flow by very quickly, but you can click on one of them to open a side panel and view the response output using the Response tab (second screenshot below). Viewing the network tab on a very active web page such as the sensors page can tax even my high end Macbook, so be careful not to leave the inspector/developer tools on the Network tab too long.

Tail or inspect the logs

You could also tail the HA log (or less) to look for any issues/errors it might be outputting. Mine is in /home/hass/.homeassistant/home-assistant.log

tail -f /home/hass/.homeassistant/home-assistant.log

You can also pipe to grep for the sensor name:

tail -f /home/hass/.homeassistant/home-assistant.log | grep kitchen_motion

Hope this helps you figure out what’s going on @anon35356645

2 Likes

The motion sensor where not active in the app. Now it works in the webserver … but still not in front end of HASS (while is working in curl)

what would be the command to get the light sensor?

no, is not working

17-01-28 14:40:22 homeassistant.util.yaml: while parsing a block mapping
  in "/home/hass/.homeassistant/configuration.yaml", line 1351, column 5
expected <block end>, but found '-'
  in "/home/hass/.homeassistant/configuration.yaml", line 1352, column 5

binary_sensor:
  - platform: rest
    - name: Note3 Motion
      sensor_class: motion
      resource: http://192.168.1.50:8080/sensors.json?sense=motion_active
      value_template: '{{ value_json.motion_active.data[0][1][0] | round(0) }}'
    - name: Note4 Motion
      sensor_class: motion
      resource: http://192.168.1.51:8080/sensors.json?sense=motion_active
      value_template: '{{ value_json.motion_active.data[0][1][0] | round(0) }}'

I’m not a Home Assistant configuration or Yaml expert, so I’m not sure exactly how to resolve your config issue. Maybe you put your whole configuration.yaml in something like http://pastebin.com/ (removing/replacing any sensitive stuff) so I and others could look at it to try and help.

I solved like this

binary_sensor 50:
  - platform: rest
    name: Note3 Motion
    sensor_class: motion
    resource: http://192.168.1.50:8080/sensors.json?sense=motion_active
    value_template: '{{ value_json.motion_active.data[0][1][0] | round(0) }}'
binary_sensor 51:
  - platform: rest
    name: Note4 Motion
    sensor_class: motion
    resource: http://192.168.1.51:8080/sensors.json?sense=motion_active
    value_template: '{{ value_json.motion_active.data[0][1][0] | round(0) }}'
1 Like

Glad you figured it out!

:wink: <—

Hopefully available in the next release (2 weeks from right now).

Absolutely excellent find @timwood and super timely for me. I was wanting to set some cameras up on Friday but all I found that was already supported was Manythings which uses IFTTT which I don’t want (everything should stay in my network as much as possible). Knocked this out over the last 24 hours or so. Hopefully it’s a vast improvement over your existing stuff.

6 Likes

Hey @robbiet480. What do you mean by this?

1 Like

Click the wink face :slight_smile:

1 Like

Sorry, didn’t notice the link. WOW! You work fast! Did you start this after my post? Thanks for developing this!

2 Likes

Wow super excited to see this in the next release!

Here is a switch to turn the ip camera’s night vision on and off.

switch:
  platform: command_line
  switches:
    cam_nv:
      command_on: "/usr/bin/curl -X GET http://192.168.1.xx1:8080/settings/night_vision?set=on"
      command_off: "/usr/bin/curl -X GET http://192.168.1.xx1:8080/settings/night_vision?set=off"
      friendly_name: Cam NightVision
1 Like

You could probably add a command_state to that switch, if you wanted, using this:

command_state: 'curl "http://IP.ADDRESS:8080/status.json"'
value_template: '{{ value_json.curvals.night_vision == "on" }}'

I don’t know if you got this in the code on your PR but this url takes a photo and saves it to storage. http://IPADDRESS:8080/photo_save_only.jpg

means it toggles the flash?

No it turns the cameras to night vision mode.So the camera can see in lower light. Have to also set the gains in the interface for it to work.

This url activates the led http://IPADDRESS:8080/enabletorch

I see.

I tested it and no changes in camera view. Maybe some cellular phones have this function and some not? How to check?