Hi,
im new to Pimatic and im trying to set an Alarmtime externaly.
I just found out how to use api to set Variable via curl.
example:
curl -X PATCH --header “Content-Type:application/json” --data ‘{“type”: “value”, “valueOrExpression”: “Mo 7:45”}’ --user “admin:pass” http://10.15.23.81:800/api/variables/testvar
I also got success on setting a rule based on this variable:
if its $testvar then switch RFSwitch1 on
This works well, if there is an alarmtime… but it generates an error, if the alarmtime is set to anything else then an alarmtime…
error [pimatic]: Error on evaluation of rule condition of rule rule1: " " is not a valid date or time.
in my szenario i am using a cron-script every 5 seconds (by using the app “cron4phone”) on my android phone to get the next set alarmtime… and send it via curl to my pimatic…
looks like this:
r=$(eval sqlite3 -column /data/data/com.android.providers.settings/databases/settings.db ‘select value from system where name = “next_alarm_formatted”’) ; curl -X PATCH --header “Content-Type:application/json” --data ‘{“type”: “value”, “valueOrExpression”: "’"$r"’"}’ --user “admin:pass” http://10.15.23.81:800/api/variables/testvar
Problem: if there is no alarmtime on the android device set… this little codeline sets the value of the pimatic variable to " ". which is not a valid date or time.
now im stuck on ideas how to solve this