Closer… when I try to add the device from the app I receive
null on line 553
which corresponds to this code:
if (state.eightSleepAccessToken) {
def now = new Date().getTime()
def sessionExpiryTime = Date.parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", atomicState.expirationDate).getTime()
I tested that line and there are no syntax issues with Date.parse or getTime(). So it looks like atomicState.expirationDate is the problem. Possibly try completely removing the app and starting over. Some values may have not been set with the previous errors. If you still have the error, click the blue i icon next to the App and check if expirationDate is listed and has a value.
So here is a shot.... there is no expirationDate at all?
![20%20PM|690x356](upload://6IqH5tpAr0B3stlDvL8c8vcLp3N.png)
Also perhaps the full log would be helpful. It seems everything initiates, just when I go to select my devices, I am not presented with choices.
2018-03-19 18:50:58.344:debuginitialize
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:58.343:debuginstalled
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:36.741:errornull on line 553
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:27.632:debugeightSleepTokenExpirationDate: 2018-04-02T22:50:27.526Z
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:27.631:debugeightSleepUserId: 2ddb0e487c814bd38ae64f95129d1774
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:27.629:debugeightSleepAccessToken: 58c148b2200a4530826c38b0ba091190-b356fa8b6bed0d19d908482c75128bfe
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:27.623:infoBody: [session:[expirationDate:2018-04-02T22:50:27.526Z, userId:2ddb0e487c814bd38ae64f95129d1774, token:58c148b2200a4530826c38b0ba091190-b356fa8b6bed0d19d908482c75128bfe]]
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:27.621:infoStatus: 200
[app:429](http://192.168.7.201/logs#app429)2018-03-19 18:50:26.925:debugBeginning API POST: /login, [emailxxxxx] <-- changed
So it does look like you’re receiving the expirationDate value which is good! Just noticed though that on line 453 where it’s set, it’s mixed with state and atomicState. From what I’ve read the two access methods shouldn’t be mixed. I’ve never tested mixing them, but try changing atomicState to state and see if there’s any change.
Try replacing app.namespace in the two addChildDevice() calls with “alyc100” . The error seems to indicate that app.namespace is ‘null’. It needs to be a string that matches the namespace: definition of your child device. In this case, that would be “alyc100”
Awesome! I committed the atomicState fix and @ogiewon's app.namespace fix to github. Once all the other bugs are sorted out we can pull the changes back into @justin.bennett's repo.
The error on line 50 could either be device.deviceNetworkId or parent being null. More logging would help narrow it down.
I'd try changing device.currentState("switch").getValue() to device.currentSwitch
So, as it turns out, I was being a bit slow. I didn’t realize that the app would create the device. Once I figured that out, deleted the device and then reloaded the app success smiled upon me.
You can try changing httpPut to httpPutJson. This is a method in the ST documentation which I haven’t tried it on Hubitat yet. If that doesn’t work, try adding in requestContentType parameter (you can add it in after headers): headers: apiRequestHeaders(), requestContentType: "application/json"
@mattw Thank you very much. I tried the httpPutJson and it now turns on and off. Would I also have to do that with the httppost? I haven’t seen anything in the logs to indicate there is a post happening, but better safe than sorry right?
@justin.bennett. Please add this to your app code and let me know where your GitHub is
That’s great! Thank you. I’m working on commenting out the code that I’m not finding helpful now. For example, he used the battery as a way to report on the sleep score. Using the battery automatically included it in my HSM battery rule (and I can use the app to see the sleep score) so I commented it out. I’m also looking at the contact switch (in bed) part to see if it works and how I can speed up the reporting of it. I’d like to drive some automation based on whether I’m in bed or not.
I can keep you updated on this if you want. I’m not sure what has value to you in the code though, and it’ll be a slow process as I continue to relearn how to program. Seems that’s taking longer than I thought.
There is definitely something strange going on. The devices will only log a poll and refresh. So, even when I select the On or Off buttons and the Device page shows the switch turning on/off, I don’t see any updates on the Events or Log pages.
Actually this is the issue, it’s within the Bed App
[app:433](http://192.168.7.201/logs#app433)2018-03-21 21:39:29.433:infoStatus: 200
[app:433](http://192.168.7.201/logs#app433)2018-03-21 21:39:25.799:errorNo encoder found for request content type */* on line 538
[app:433](http://192.168.7.201/logs#app433)2018-03-21 21:39:25.793:debugBeginning API POST: /devices/3b0037000151363133343338, [leftHeatingDuration:11700]
[app:433](http://192.168.7.201/logs#app433)2018-03-21 21:39:23.792:errorNo encoder found for request content type */* on line 538
[app:433](http://192.168.7.201/logs#app433)2018-03-21 21:39:23.779:debugBeginning API POST: /devices/3b0037000151363133343338, [leftTargetHeatingLevel:10, leftHeatingDuration:11700]