Thanks for making this. I have the setup more-or-less as documented with a Pi running a few sprinkler relays.
Several times now I have had the web app become completely unresponsive and irrigation stop functioning. The webapp lists a 502 error. None of the cron jobs function and a reboot does not resolve the issue.
When I ssh into the device I see that events.log is full of the message Exception occurred when reading irrigator.json. Value Error Exception - JSONDecodeError. Retrying.
When I dig into irrigator.json and run it on a JSON validator I see that it is invalid JSON. The JSON file has an extra closing brace near the end of the file. Since there is a check to retry the parsing here
|
event = f'Exception occurred when reading {json_data_filename}. Value Error Exception - JSONDecodeError. Retrying.' |
it blows up into an infinite recursion and ultimately crashes the device.
I am not sure when a JSONDecodeError would be resolved simply by retrying the parse or what the logic behind this method to retry is. But for my application I find it crashes my setup and because I live in a hot climate I notice the lack of water quickly.
A band-aid fix would be to nix the retry logic. On my Pi I've created a backup.json which I go and restore via SSH but I am considering changing the code to automatically replace the corrupted JSON with my backup. But this begs the question as to what's corrupting the JSON in the first place. I'd like to resolve the core issue if it isn't too much to troubleshoot.
The error doesn't seem explicitly related to me changing settings or updating schedules, as I will leave the pi/webapp unattended for days at a time and notice the JSON has been corrupted. Maybe something in the logic to read/update settings and write out the JSON is causing it?
Here is my standard irrigator.json (before any corruption) for reference.
{
"controls": {
"manual_override": false,
"active": true
},
"settings": {
"target_sys": "RasPi",
"zone_gate": 29,
"relay_trigger": 0
},
"wx_data": {
"apikey": "70a98446a75e1fe9990da13473ffd99d",
"lat": "33.4484367",
"long": "-112.074141",
"location": "Phoenix, AZ, USA",
"temp_enable": true,
"min_temp": 32,
"max_temp": 130,
"precip": 0.2,
"history_enable": true,
"history_hours": 24,
"forecast_hours": 24,
"forecast_enable": true,
"forecast_history_enable": true,
"units": "F",
"history_days": 2,
"forecast_days": 2
},
"zonemap": {
"Grass": {
"GPIO_mapping": 31,
"enabled": true,
"active": false
},
"Shrubs": {
"GPIO_mapping": 32,
"enabled": true,
"active": false
},
"Veggies": {
"GPIO_mapping": 33,
"enabled": true,
"active": true
}
},
"schedules": {
"Veggies_Morning": {
"start_time": {
"enabled": true,
"minute": 0,
"hour": 6,
"day_of_month": "",
"month": "",
"day_of_week": "",
"cron_string": "0 6 * * ",
"human_readable": "At 06:00 AM",
"active": false
},
"zones": {
"Grass": {
"duration": 0
},
"Shrubs": {
"duration": 0
},
"Veggies": {
"duration": 10
}
}
},
"Lawn_Semiweekly": {
"start_time": {
"enabled": true,
"minute": 0,
"hour": 7,
"day_of_month": "",
"month": "",
"day_of_week": "Mon,Thu",
"cron_string": "0 7 * * Mon,Thu",
"human_readable": "At 07:00 AM, only on Monday and Thursday",
"active": false
},
"zones": {
"Grass": {
"duration": 30
},
"Shrubs": {
"duration": 0
},
"Veggies": {
"duration": 0
}
}
},
"Shrubs_Semiweekly": {
"start_time": {
"enabled": true,
"minute": 0,
"hour": 7,
"day_of_month": "",
"month": "",
"day_of_week": "Tue,Fri",
"cron_string": "0 7 * * Tue,Fri",
"human_readable": "At 07:00 AM, only on Tuesday and Friday",
"active": false
},
"zones": {
"Grass": {
"duration": 0
},
"Shrubs": {
"duration": 60
},
"Veggies": {
"duration": 0
}
}
}
}
}
Thanks for making this. I have the setup more-or-less as documented with a Pi running a few sprinkler relays.
Several times now I have had the web app become completely unresponsive and irrigation stop functioning. The webapp lists a 502 error. None of the cron jobs function and a reboot does not resolve the issue.
When I ssh into the device I see that
events.logis full of the messageException occurred when reading irrigator.json. Value Error Exception - JSONDecodeError. Retrying.When I dig into
irrigator.jsonand run it on a JSON validator I see that it is invalid JSON. The JSON file has an extra closing brace near the end of the file. Since there is a check to retry the parsing hereirrigator/common.py
Line 36 in 93d95aa
I am not sure when a JSONDecodeError would be resolved simply by retrying the parse or what the logic behind this method to retry is. But for my application I find it crashes my setup and because I live in a hot climate I notice the lack of water quickly.
A band-aid fix would be to nix the retry logic. On my Pi I've created a
backup.jsonwhich I go and restore via SSH but I am considering changing the code to automatically replace the corrupted JSON with my backup. But this begs the question as to what's corrupting the JSON in the first place. I'd like to resolve the core issue if it isn't too much to troubleshoot.The error doesn't seem explicitly related to me changing settings or updating schedules, as I will leave the pi/webapp unattended for days at a time and notice the JSON has been corrupted. Maybe something in the logic to read/update settings and write out the JSON is causing it?
Here is my standard
irrigator.json(before any corruption) for reference.