Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crash from corrupt thermostat record #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rossbeazley
Copy link

The cube is unstable (i understand) and so its possible for max to stop working when this happens, boiler control will stop and things can get a little frosty ;)

output might be like

$ ~/workspace/eq3/eq3-max/bin/max 
Found cube at 192.168.10.145
Unexpected device 0cfb4d at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Can't call method "_set" on an undefined value at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 129, <GEN2> line 7.

even forgetting the device cant work

$ ~/workspace/eq3/eq3-max/bin/max forget 0cfb4d
Found cube at 192.168.10.145
Unexpected device 0cfb4d at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Can't call method "_set" on an undefined value at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 129, <GEN2> line 7

this PR simply guards against this undefined $device

and even though it looks like things are not good, the device can then be forgotten and things recover

$ ~/workspace/eq3/eq3-max/bin/max forget 0cfb4d
Found cube at 192.168.10.145
Unexpected device 0cfb4d at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Unexpected device 0ad98d at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Unexpected device 09ed2a at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Unexpected device 0bda40 at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Unexpected device 0bda32 at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Unexpected device 09ed35 at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Unexpected device 0bef2a at /home/rdlb/workspace/eq3/eq3-max/bin/../lib/Max.pm line 126, <GEN2> line 7.
Done.

$ ~/workspace/eq3/eq3-max/bin/max 
Found cube at 192.168.10.145
* Kitchen(1)         0.0 →  0.0   
* TV(2)              0.0 → 21.5    74%
* Conservatory(3)   18.2 → 19.5    65%
* Tech Room(4)       0.0 → 19.0     0%
* Hall(5)           20.0 → 20.5    25%
* Bedroom 2(6) 19.6 → 19.0    13%
* Bathroom(7)       18.6 → 19.5    20%
* Bedroom(8)         0.0 → 19.0     0%
* Office(9)     0.0 → 18.5     0%
* Loft(10)           0.0 → 18.0     0%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant