Recently bought a “smart” fridge/freezer but the only “off-the-shelf” alarms appear to be the Set Temp for both the freezer or fridge (which is basically useless as I guess you would remember what target temperatures you did set ???). But I can “see” the actual temps on the SmartThings web interface. Ssurely someone has written the JSON code to send an alarm when the actual temperature exceeds X degrees ?
So you have temperatureMeasurement and temperature or something like coolingSetpoint, right?
If you have another temperature sensor device, you could create a routine in the SmartThings app, use this as a JSON template and replace the device ID of the sensor with the one of the fridge.
Something like that.
Thanks, I tried to use the JSON code for the coolingsetpoint alarm and replaced it with the temperatureMeasurement elements but could not get the code accepted…Error 400 something, will not accept “type”…
Hoping somebody would be willing to share a sample JSON code for freezer alarm
Edit: you’ve just edited your comment…
Alright. I’ll try to explain.
Step 1: Create routine with some sensor:
Step 2: Find routine in web interface:
Step 3: copy the JSON:
Step 4: edit the device ID and maybe the attribute:
Step 5: save it in a your newly created rule.
You can actually use other device types as a template if you know what you are doing. You can also use a virtual temperature sensor device to create the template.
Vielen Dank Andreas
I have successfully created a Routine on the ST App (which sends me a SMS message when the outdoor temp is above 10F…). I can see this rule on the Web interface. but when I copy exactly the same to add a new rule on the web interface, it tells me that it does not recognize the “type”… (the same type of error I get when I buyild my own rule based on my device = freezer etc…
It appears that the web interface has issues recognizing any “type” statement ?
Error adding rule “Test 12F”. 422 Unprocessable Entity The request is malformed. type: Unrecognized field “type” (class v20190122.internal.st.behaviors.Operand), not marked as ignorable…
Actual JSON:
[
{
“if”: {
“greaterThanOrEquals”: {
“left”: {
“location”: {
“locationId”: “1e45eb38-ada8-4285-868a-f65180ddb19c”,
“attribute”: “TemperatureF”,
“trigger”: “Always”
},
“type”: “location”
},
“right”: {
“decimal”: 10,
“type”: “decimal”
},
“aggregation”: “Any”,
“changesOnly”: true
},
“type”: “greaterThanOrEquals”,
“then”: [
{
“notification”: {
“sms”: {
“message”: “test”,
“recipients”: [
“sms:+15712773906”
],
“entityId”: “d0fc32aa-981f-4139-9aa0-357af94974e4”,
“messageGroupSet”: “92a0a451-069e-4d47-ba9e-e2e54724ee9c”,
“messageGroupKey”: “3662487f_a990_43df_88cf_9be240183cdb”
},
“type”: “sms”
},
“type”: “notification”
}
],
“sequence”: {
“then”: “Parallel”,
“else”: “Parallel”
}
},
“type”: “if”
}
]
Because your device (freezer) isn’t a location…
Compare your JSON with my example. Do you see a location in mine?
The following JSON might not be complete - difficult to c&p on a tablet.
[
{
"if": {
"greaterThanOrEquals": {
"left": {
"device": {
"devices": [
"d2736c37-bc5b-4330-bb16-3673fc8a36ba"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature",
"trigger": "Always"
},
"type": "device"
},
"right": {
"decimal": 12,
"type": "decimal"
},
"changesOnly": true
},
"type": "greaterThanOrEquals",
"then": [
{
"notification": {
"push": {
"title": "Temp Test Message",
"message": "Test Message"
},
"type": "push"
},
"type": "notification"
}
],
"sequence": {
"then": "Parallel",
"else": "Parallel"
}
},
"type": "if"
}
]
I simply wanted to make the point that ANY Type statement is not accepted … I have tried your JSON and again get the same error message… See below
Am I simply using the wrong place to add these rules ???
I see another post which indicates that “type” statement are not allowed in the API interface:
(A problem occurred while creating rules. Please let me know what is the problem!)
So try it without the type?
I could do it for you, but I’m in the middle of nowhere right now…
Thanks for offering
I have tried deleting all types but seems to get nowhere…
I am not in a hurry but want to avoid having to buy another sensor to get this alarm working !
As far as I know, it is not possible to make notifications using the Rules API.
Notifications are only possible using ST App routines.
Paste your rule here.
Make sure to add ``` before and after - like this:
```
type or paste code here
```
Time for a virtual switch…
This is the rule which causes me trouble:
‘’‘’
[
{
“if”: {
“equals”: {
“left”: {
“device”: {
“devices”: [
“fc50547a-7f2d-ec46-ed3a-ccdceb880f6f”
],
“component”: “freezer”,
“capability”: “temperatureMeasurement”,
“attribute”: “temperature”,
“trigger”: “Always”
},
“type”: “device”
},
“right”: {
“decimal”: -10,
“type”: “decimal”
},
“aggregation”: “Any”,
“changesOnly”: false
},
“type”: “equals”,
“then”: [
{
“notification”: {
“push”: {
“title”: “Push message when Freezer is at -10 C or above”,
“message”: “Freezer is above -10C”,
“target”: {
“locationId”: “1e45eb38-ada8-4285-868a-f65180ddb19c”,
“userUuids”: [
“a0edff30-9dbf-49f8-eff9-b3468d8cc20d”
]
}
},
“type”: “push”
},
“type”: “notification”
}
],
“sequence”: {
“then”: “Parallel”,
“else”: “Parallel”
}
},
“type”: “if”
}
]
‘’‘’
See above. You can’t send notifications with the Rules API.
As a workaround:
Create a virtual switch:
Use this virtual switch in your Rule, like IF temperature THEN turn on switch. You’d have to create a JSON template first and modify it accordingly.
Create a routine in the ST app: IF virtual switch on THEN send message.
Or just buy a temperature sensor.
Great idea (workaround)
But I get the same error when trying to save this new rule: (I must be missing something fundamental as the web interface seems to refuse ANY “type” statements…
Error adding rule “Turn on Vswitch when freezer temp is >-10”. 422 Unprocessable Entity The request is malformed. type: Unrecognized field “type” (class v20190122.internal.st.behaviors.Operand), not marked as ignorable
JSON code follows:
“”"
[
{
“if”: {
“greaterThanOrEquals”: {
“left”: {
“device”: {
“devices”: [
“fc50547a-7f2d-ec46-ed3a-ccdceb880f6f”
],
“component”: “freezer”,
“capability”: “temperatureMeasurement”,
“attribute”: “temperature”,
“trigger”: “Always”
},
“type”: “device”
},
“right”: {
“decimal”: -10,
“type”: “decimal”
},
“aggregation”: “Any”,
“changesOnly”: true
},
“type”: “greaterThanOrEquals”,
“then”: [
{
“command”: {
“devices”: [
“9b3a32f0-d009-4241-af83-0e1be9cb3596”
],
“commands”: [
{
“component”: “main”,
“capability”: “switch”,
“command”: “on”
}
],
“sequence”: {
“commands”: “Serial”,
“devices”: “Serial”
}
},
“type”: “command”
}
],
“sequence”: {
“then”: “Parallel”,
“else”: “Parallel”
}
},
“type”: “if”
}
]
Thanks Andreas, the alarm based on a Virtual Switch is working now (I had to suppress all “type” statements…)
For use by anyone else (obviously change your device ID):
[
{
“if”: {
“greaterThanOrEquals”: {
“left”: {
“device”: {
“devices”: [
“fc50547a-7f2d-ec46-ed3a-ccdceb880f6f”
],
“component”: “freezer”,
“capability”: “temperatureMeasurement”,
“attribute”: “temperature”,
“trigger”: “Always”
}
},
“right”: {
“decimal”: -17
},
“aggregation”: “Any”,
“changesOnly”: true
},
“then”: [
{
“command”: {
“devices”: [
“87291908-69b7-446c-8ef4-a8e34e51c551”
],
“commands”: [
{
“component”: “main”,
“capability”: “switch”,
“command”: “on”
}
],
“sequence”: {
“commands”: “Serial”,
“devices”: “Serial”
}
}
}
],
“sequence”: {
“then”: “Parallel”,
“else”: “Parallel”
}
}
}
]
Very cool.
Have you seen this?
Imagine having a virtual temperature sensor instead of a virtual switch!
It would have all the features of a real sensor.
It is not possible to modify the JSON code for app created rules (aka Routine) so they are saved as API rules.
The “type”, metadata that comes in all routines must be removed to save as an API rule.
You now know how to create API rules which have many more possibilities
Disadvantage is you can’t see them in the app on your phone.