gytisgreitai / openhab-google-home

13 stars 1 forks source link

Error with complex light #14

Open mtzro2003 opened 4 years ago

mtzro2003 commented 4 years ago

Hello Gytis,

Still maintaining this? 😄

I'm trying to replicate the complex light example you gave in the docs. Here are my items:

Group gLivingroom_Light "Livingroom Light" {google="action.devices.types.LIGHT" [roomHint="Livingroom"]}

Switch Livingroom_Light_Switch "Livingroom Light Switch" <light> (gLivingroom_Light) {channel="hue:group:00178840fd2f:1:switch", google="action.devices.traits.OnOff"}
Dimmer Livingroom_Light_Brightness "Livingroom Brightness" <light> (gLivingroom_Light) {channel="hue:group:00178840fd2f:1:brightness", google="action.devices.traits.Brightness"}
Dimmer Livingroom_Light_ColorTemperature "Livingroom Light Temp." (gLivingroom_Light) {channel="hue:group:00178840fd2f:1:color_temperature"}
Color Livingroom_Light_Color "Livingroom Light Color" (gLivingroom_Light) {channel="hue:group:00178840fd2f:1:color"}

When syncing, I got the following error in the container logs (using 'app-only'):

Request {                                                                                                                                                                                                                                                   
  "inputs": [                                                                                                                                                                                                                                               
    {                                                                                                                                                                                                                                                       
      "intent": "action.devices.SYNC"                                                                                                                                                                                                                       
    }                                                                                                                                                                                                                                                       
  ],                                                                                                                                                                                                                                                        
  "requestId": "14767033563091986596"                                                                                                                                                                                                                       
}                                                                                                                                                                                                                                                           
Headers {                                                                                                                                                                                                                                                   
  "host": "XXXX.XX.XX:8443",                                                                                                                                                                                                                               
  "x-real-ip": "XX.XX.XX.XX",                                                                                                                                                                                                                               
  "x-forwarded-for": "XX.XX.XX.XX",                                                                                                                                                                                                                         
  "x-forwarded-proto": "https",                                                                                                                                                                                                                             
  "connection": "close",                                                                                                                                                                                                                                    
  "content-length": "80",                                                                                                                                                                                                                                   
  "content-type": "application/json;charset=UTF-8",                                                                                                                                                                                                         
  "google-assistant-api-version": "v1",                                                                                                                                                                                                                     
  "authorization": "Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",                                                                                                                                                               
  "user-agent": "Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)",                                                                                                                                                    
  "accept-encoding": "gzip,deflate,br"                                                                                                                                                                                                                      
}                                                                                                                                                                                                                                                           
sync error TypeError: Cannot read property 'google' of undefined                                                                                                                                                                                            
    at Object.toGoogleDevice (/opt/app/sync/sync.js:65:68)                                                                                                                                                                                                  
    at /opt/app/smarthome.js:65:51                                                                                                                                                                                                                          
    at Array.forEach (<anonymous>)                                                                                                                                                                                                                          
    at /opt/app/smarthome.js:61:27                                                                                                                                                                                                                          
    at step (/opt/app/smarthome.js:33:23)                                                                                                                                                                                                                   
    at Object.next (/opt/app/smarthome.js:14:53)                                                                                                                                                                                                            
    at fulfilled (/opt/app/smarthome.js:5:58)                                                                                                                                                                                                               
    at <anonymous>

What am I doing wrong? Thanks, Mihai

gytisgreitai commented 4 years ago

Still maintaining this?

Not really :) I think the new official implementation is now way a head

What am I doing wrong?

Probably nothing, My assumption was that there will always be metadata, which does not seem to be the case. I'll try push new version sometime later today or tomorrow, in the meantime, you can add some dummy metadata like e.g. synonyms="Whatever" to the Livingroom_Light_ColorTemperature and Livingroom_Light_Color items

mtzro2003 commented 4 years ago

Not really :) I think the new official implementation is now way a head

Be that as it may, but your approach is much more 'friendly' with self-hosted application... Depending on myopenhab.org gave my a lot of headaches and delays over time... Ofcourse, one could host his own openhab cloud instance, but it was really a pain in the a$$ when it tried that... Ever since I switched to your app, I never looked back :smile: It's a pity that you don't maintain it anymore... Do you still use it? Or did you switch to the official?

My assumption was that there will always be metadata

Tried you suggestion, but it was the same... However, it looks like I found the culprit... Seems that it didn't like that I have items with no trait in the same group. I removed the other items from the group and now it's syncing and working. Maybe you can treat this case... Here are the items now - notice that ColorTemperature and Color are not part of gLivingroom_Light anymore:

Group gLivingroom_Light "Livingroom Light" {google="action.devices.types.LIGHT" [roomHint="Livingroom"]}

Switch Livingroom_Light_Switch "Livingroom Light Switch" <light> (gLivingroom_Light) {channel="hue:group:00178840fd2f:1:switch", google="action.devices.traits.OnOff"}
Dimmer Livingroom_Light_Brightness "Livingroom Brightness" <light> (gLivingroom_Light) {channel="hue:group:00178840fd2f:1:brightness", google="action.devices.traits.Brightness"}

Dimmer Livingroom_Light_ColorTemperature "Livingroom Light Temp." {channel="hue:group:00178840fd2f:1:color_temperature"}
Color Livingroom_Light_Color "Livingroom Light Color" {channel="hue:group:00178840fd2f:1:color"}
gytisgreitai commented 4 years ago

Do you still use it? Or did you switch to the official?

Yes, still using, mostly for the same reasons. But I've seen on the forums that they've fixed a lot of issues and moved forward quite a bit.

I've released a possible fix under app-only-beta tag. There were some changes in between therefore had to restructure the Docker image, so not sure if it will work

mtzro2003 commented 4 years ago

Well, if you'll continue your project I'll stand by your side :smile: and help with whatever I can. :laughing: I pulled app-only-beta and here the log of a sync my devices request app-only-beta.log It looks like it's working properly :+1: