Rosie, AJAX and JSON
I've been working in modernising the software side of Rosie. At first, I wanted a module which would tell me whether my lights were on or off. As a rudimentary first attempt, I just had a module which loaded the current state of each light and visually displayed it at the top of the page. I then used some JavaScript to refresh it every second.
This works well, especially on wi-fi. You can't see the refresh and as soon as a light comes on or goes off, the little graphical bulb goes off. The problem is, a) it's horrendous for battery usage, especially on a tablet or phone, b) it doesn't work well over 3g, with the module visually disappearing and then reloading and c) it's an awful solution I'm definitely not proud of.
So I set to work yesterday to return an array encoded into json. Then I read that response back from my AJAX query and use that to update the lights. The response comes back as an array containing the ID of the light and the state it has switched to (on or off). I can then use this to update the styling of the particular light to show it as on or off.
Next I need to do an occasional check on the database to see whether another device is controlling the lights. This is rare but if I set a delay on the light e.g. in 5 minutes turn XX off, then I need to control that as well.
Motorbike
Today was a glorious day so rather than sitting on the sofa watching "background tv" whilst coding AJAX, JSON and PHP, I decided to get on my motorbike and go for a ride. I rode from Bramley, Hampshire to Streatley, Oxfordshire. I took a few pictures up there for around 30 minutes and then headed back, completing a circular route. It was a great route and great ride.
This week
This week is a bit busy. I'm practically touring Germany with a trip back to the UK in the middle.
On Monday, I travel to Frankfurt. I am there all of Tuesday and travel back Tuesday night. I then go into the office on Wednesday morning before heading back to Heathrow Wednesday lunchtime to fly to Berlin. I stay in Berlin all day Thursday and then head back. Friday, I aim to stay in one place all day - Reading.
I have a feeling I'm going to be tired on Friday. It's not quite the craziest week I've ever had though and it's definitely going to be interesting. It'd be easy if I didn't have some heavy-going meetings whilst at these locations.
Fortunately, I use a great app called Trip Case for managing my trips. Usually, it's just handy to have the entire trip in one app, but this week it's necessary. Different airlines, times, hotels and terminals would have me thoroughly confused otherwise.
Netflix... conforming
I, by default, am a non-conformist. I think there is 20% of me which naturally conforms (I'm not unfashionable, I like my house to be tidy, I follow social etiquette etc) but the other 80% likes to do my own thing.
For example, I tend to have the latest gadgets, but that's not so that I look cool in the street. Actually, I typically end up trying not to show them off because I only buy them because I love gadgets.
So, what happens is I sometimes stay away from the latest fads, because I don't want to be one of a crowd. This has it's disadvantages, for example I am very late to Breaking Bad, I haven't watched any Game of Thrones (but now want to) and am late to joining Netflix. I have tried it this weekend and it's brilliant. I really like it. I'm using it through my Xbox 360 but since I can use it everywhere, I'm impressed. Whether I use it enough to justify it's cost is another question.
I've been working in modernising the software side of Rosie. At first, I wanted a module which would tell me whether my lights were on or off. As a rudimentary first attempt, I just had a module which loaded the current state of each light and visually displayed it at the top of the page. I then used some JavaScript to refresh it every second.
This works well, especially on wi-fi. You can't see the refresh and as soon as a light comes on or goes off, the little graphical bulb goes off. The problem is, a) it's horrendous for battery usage, especially on a tablet or phone, b) it doesn't work well over 3g, with the module visually disappearing and then reloading and c) it's an awful solution I'm definitely not proud of.
So I set to work yesterday to return an array encoded into json. Then I read that response back from my AJAX query and use that to update the lights. The response comes back as an array containing the ID of the light and the state it has switched to (on or off). I can then use this to update the styling of the particular light to show it as on or off.
Next I need to do an occasional check on the database to see whether another device is controlling the lights. This is rare but if I set a delay on the light e.g. in 5 minutes turn XX off, then I need to control that as well.
Motorbike
Today was a glorious day so rather than sitting on the sofa watching "background tv" whilst coding AJAX, JSON and PHP, I decided to get on my motorbike and go for a ride. I rode from Bramley, Hampshire to Streatley, Oxfordshire. I took a few pictures up there for around 30 minutes and then headed back, completing a circular route. It was a great route and great ride.
This week
This week is a bit busy. I'm practically touring Germany with a trip back to the UK in the middle.
On Monday, I travel to Frankfurt. I am there all of Tuesday and travel back Tuesday night. I then go into the office on Wednesday morning before heading back to Heathrow Wednesday lunchtime to fly to Berlin. I stay in Berlin all day Thursday and then head back. Friday, I aim to stay in one place all day - Reading.
I have a feeling I'm going to be tired on Friday. It's not quite the craziest week I've ever had though and it's definitely going to be interesting. It'd be easy if I didn't have some heavy-going meetings whilst at these locations.
Fortunately, I use a great app called Trip Case for managing my trips. Usually, it's just handy to have the entire trip in one app, but this week it's necessary. Different airlines, times, hotels and terminals would have me thoroughly confused otherwise.
Netflix... conforming
I, by default, am a non-conformist. I think there is 20% of me which naturally conforms (I'm not unfashionable, I like my house to be tidy, I follow social etiquette etc) but the other 80% likes to do my own thing.
For example, I tend to have the latest gadgets, but that's not so that I look cool in the street. Actually, I typically end up trying not to show them off because I only buy them because I love gadgets.
So, what happens is I sometimes stay away from the latest fads, because I don't want to be one of a crowd. This has it's disadvantages, for example I am very late to Breaking Bad, I haven't watched any Game of Thrones (but now want to) and am late to joining Netflix. I have tried it this weekend and it's brilliant. I really like it. I'm using it through my Xbox 360 but since I can use it everywhere, I'm impressed. Whether I use it enough to justify it's cost is another question.
No comments:
Post a Comment