Hi @cabrioartie Welcome to the Community! Looking at what you want to do, If you go through the API documentation you can check the rules creation part description, you can create a between clause using the time data type, which accepts the following values:
“Now”, “Midnight”, “Sunrise”, “Noon”, “Sunset”
Something like the following might be useful for you, of course if you want more than one condition, then you’ll need the and clause.
{
"name": "If the time is between sunset and sunrise",
"actions": [
{
"if": {
"between": {
"value": {
"time": {
"timeZoneId": "America/Argentina/Buenos_Aires",
"reference": "Now"
}
},
"start": {
"time": {
"timeZoneId": "America/Argentina/Buenos_Aires",
"reference": "Sunset"
}
},
"end": {
"time": {
"timeZoneId": "America/Argentina/Buenos_Aires",
"reference": "Sunrise"
}
}
},
"then": [
{
"command": {
"devices": [
"2316d9b8-8bc3-4ecd-af1d-94096fe9eaa9"
],
"commands": [
{
"component": "main",
"capability": "switch",
"command": "on",
"arguments": []
}
]
}
}
]
}
}
]
}
Please let me know if this is useful for your use case.
Regarding the errors, they are also described in the documentation, but as a personal experience I recommend you to use a JSON parser to check the format, which is where the most common errors are.
And you’ll get a message similar to this one:
{
"requestId": "606784EB-A493-4794-A8BF-46FA1E66ABBD",
"error": {
"code": "ConstraintViolationError",
"target": null,
"message": "The request is malformed.",
"details": [
{
"code": "BodyMalformedError",
"target": "",
"message": "Malformed body on line 4",
"details": []
}
]
}