My Foscam C1-lite provides noise values.
It would be nice to use them within hass (e.g. as trigger in alarm control).
A native solution would be nice, but you can also do this via the curl commandline. I have mine doing both motion and sound detection this way.
Sounds very interesting.
Could you share your config?
I never went into the curl route as the cameras normally output in XML format and thought converting to a template would be harder. I decided to use the a python library. Install the foscam-python-lib
save the following as foscam (chmod +x):
#!/usr/bin/env python
if __name__ == '__main__':
import argparse
import json
from foscam import FoscamCamera
parser = argparse.ArgumentParser()
parser.add_argument("-H", "--host", help="camera host/ip")
parser.add_argument("-P", "--port", help="camera port", type=int)
parser.add_argument("-u", "--username", help="camera username")
parser.add_argument("-p", "--password", help="camera password")
parser.add_argument("-v", "--verbose", action="store_true",
help="increase output verbosity")
args = parser.parse_args()
if args.verbose:
print("verbosity turned on")
print(json.dumps(FoscamCamera(args.host, args.port, args.username, args.password,verbose=args.verbose).get_dev_state()[1]))
Then in your HA configuration.yml
sensor:
- platform: command_line
name: foscam_motion
command: '/config/foscam-python-lib/foscmd -H camera1ip -P 88 -u admin -p pass'
#value_template: '{{ value_json.motionDetectAlarm }}'
value_template: '{% if value_json.motionDetectAlarm == "0" %} disarm {% elif value_json.motionDetectAlarm == "1" %} off {% else %} on {% endif %}'
- platform: command_line
name: foscam_sound
command: '/config/foscam-python-lib/foscmd -H camera1ip -P 88 -u admin -p pass'
value_template: '{% if value_json.soundAlarm == "0" %} disarm {% elif value_json.soundAlarm == "1" %} off {% else %} on {% endif %}'