i need a little help with adding a sensor, i read on the community that creating a sensor by using a curl command is only creating a temporary one.which causes an problem
Now here’s what i’m trying to do
I’,m using Motion : ( http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome ) to manage some usb camera and i managed to configure some swithc in HA to stop saving the the files using a command line switch and some automation. this works perfectly.
but now what i’m struggling with is a post action from motion to tell HA when a motion is detected on the webcam.
What i’ve tried to date is to create a curl command from Motion to HA > curl -X POST -H "Content-Type:application/json" https://mydomain.net/api/states/sensor.cam_motion?api_password=XXXXXX -d '{"attributes": {"friendly_name": "Motion sensor Cam intérieur"}, "state": "on"}'
Which works fine and gives me a sensor in HA ( temp one )
But then i’m trying to get the last update time / date from it and i can’t manage to get it as the states.sensor.xxx…last_updated. doni’t work as i expected , probably due to a the temp sensor.
So , anyone of you would have a better idea to receive the state of the motion detection and be able to build some automation from it.
any idea , anyone , i’m open to try any suggestions
This is exactly my problem @PhyberApex , there is no sensor configuration as it’s created but the curl post and that creates a temporary sensor which will disappear if i restart HA which is acceptable for the case i have .
the sensor appear though behave as the others , it’s displayed in the FE and it can be reached through the api
and it’s created using the curl post command above. nothing else.
This is why i’m asking if there is a better way , as i think this , even if it seems to work , might not have all that is needed to be used in automation ( like detecting when it was last updated , etc … )
Tried it and does not seems to do much , looking at the state tab , nothing gets created ( device wise )
Did not know you could add a sensor without specifying a platform though ! it’s te case ?
@PhyberApex , tested it all out since yesterday without success , when i make an http post to any sensor, it does not change the last updated or last changed value .
So
I changed my strategy
I made a small bash script that touch a local file when movement is detected , then i configured a command_line sensor that monitor the modification date / time of the file
This works perfectly and now i can automate my stuff based on that sensor. The only caveat is that it takes around 1 min to refresh the sensor value but i can live with that