cgiesche / streamdeck-homeassistant

Control your Home Assistant devices from StreamDeck
MIT License
805 stars 39 forks source link

Plugin failing to communicate #227

Closed kBraDrs closed 8 months ago

kBraDrs commented 9 months ago

Hello,

I have installed the plugin for home-assistant, input the url of the instance, and input the long-lived access token. But am unable to control my devices with it.

The devices in my home show up, so I know that the connection is active and working, and when I switch devices on/off in the home-assistant web app, the status on the stream deck changes, so I can see when devices are on or off with it.

Screenshots are below of what my settings are, is this something that you know how to fix?

image

image

image

kBraDrs commented 9 months ago

For addition, I cannot see any requests for this in the homeassistant logs, and there are also no debug methods that I can find for the streamdeck plugin.

cgiesche commented 9 months ago

Normally, between Service and Service data, there should be a third drop-down where you can select the entity you want to turn on. If it is not visible, this normally means, that there isn't any light entity that supports the turn-on service. Maybe you have to use the "switch" domain instead of "light"?

Screenshot_20231223_194337_GitHub.jpg

kBraDrs commented 9 months ago

I see, I can confirm that none of the domains allow me to choose an entity for this. I will have a play around in HomeAssistant to see if anything needs to be changed there, if you have any ideas, please let me know. 😊

kBraDrs commented 9 months ago

I have wathced other videos on how to do this and they do not have what you are saying, but do have the below, which is a screenshot from my machine so to confirm that I can see this and have set this correctly.

image

Also, to rule out any other affecting factors, I have re installed Home Assistant to try and get this working so this is the only entity linked to it.

kramttocs commented 9 months ago

If you got to Developer > Services in HA and use the light.turn on service. Does your entity show up and respond?

kBraDrs commented 9 months ago

Yes I have just done this and it turned the light.turn_on service worked and vice versa

joestump commented 9 months ago

@kBraDrs I had this happen to me as well. Are you on 2.4.2? Try rolling back to 2.4.1 and disabling auto updates. I had the same issue as you it sounds like: https://github.com/cgiesche/streamdeck-homeassistant/issues/193#issuecomment-1868189281

kBraDrs commented 9 months ago

@kBraDrs I had this happen to me as well. Are you on 2.4.2? Try rolling back to 2.4.1 and disabling auto updates. I had the same issue as you it sounds like: #193 (comment)

That was it! It's working perfectly. I have quite a complex networking system at home and spent all of yesterday tracking down whether my network was blocking internal websocket requests 😂 Glad to find out it was this simple all along.

Thank you @joestump, you have made my morning 😊

@cgiesche Any idea why the newer version is not working correctly?

cgiesche commented 9 months ago

Oh ****.

It's my friend Jesus birthday today and I am far away from my computer for some time.

I have no idea what is going on but I will try to get the store version rolled back to the last working version. This may take some time...

As a workaround, you need to install the "latest" release (2.4.1) manually and disable auto update from store.

Sorry for that poisoned Christmas gift :D

joestump commented 9 months ago

@kBraDrs I have a similarly complex network with multiple VLANs and was worried that was an issue, but all of the devices were on the same VLAN. Interesting that there's overlap in our setup; wonder if there's something (bad network dependency update?) in 2.4.2 causing issues with VLAN tagging?

cgiesche commented 9 months ago

I am not at home, so I can not really check what it is, but it seems to be a general bug and not related to your network setups.

joestump commented 9 months ago

Not sure if others are dealing with this, but even with "Automatically update" unchecked the plugin is auto-updating nightly, which breaks things all over again. Presumably the Stream Deck software itself has a bug that ignores disabled auto-updates. 😢

Is it possible to pull the 2.4.2 release?

cgiesche commented 9 months ago

Hello everyone.

I just got home and immediately tried to reproduce the issue. I completely uninstalled the plugin and installed the current version (2.4.2) from the Elgato Store. "Unfortunately," everything seems to be working as expected on my end:

image image

Does this issue occur with existing buttons (those that existed before the update) or with newly configured ones as well?

joestump commented 9 months ago

I started an entirely new profile with new buttons and nothing worked. It also persisted across two computers as new profiles with new buttons failed to address the issue. Both macOS and Windows 11.

moosetheory commented 9 months ago

I believe I am experiencing this issue as well. I just installed today (1 January 2024). I originally installed from the Elgato Marketplace and received version 2.4.2. After I was unable to get that to function, I did some googling, and stumbled across this. Downgrading to the 2.4.1 build from github did not alleviate my issue though. The biggest difference I can think of between my config and others is that I am using the remote domain. I have also tried uninstalling and purging everything I could find from the Stream Deck software and reinstalled, only using the 2.4.1 build, but I am seeing the same behavior.

moosetheory commented 9 months ago

I believe I am experiencing this issue as well. I just installed today (1 January 2024). I originally installed from the Elgato Marketplace and received version 2.4.2. After I was unable to get that to function, I did some googling, and stumbled across this. Downgrading to the 2.4.1 build from github did not alleviate my issue though. The biggest difference I can think of between my config and others is that I am using the remote domain. I have also tried uninstalling and purging everything I could find from the Stream Deck software and reinstalled, only using the 2.4.1 build, but I am seeing the same behavior.

So, after being stumped by this yesterday, suddenly, today it has the Entity... I am confused, but it works for me now on 2.4.1. It may have something to do with the version of Home Assistant I had been running? Due to a stuck firmware update for one of my Inovelli dimmers, I had to force the docker containers I'm using to update, by deleting the old ones and downloading the latest. This is the only change I can think of, beyond time, that may have impacted things.

forcepd commented 9 months ago

Wanted to share I am seeing the same issue on a new install on 2.4.2 from the Marketplace. The status on the icon appears to be syncing correctly (e.g. when I turn the light on/off the change shows on the button). But I can't get the short press or long press to work and both are missing the "Entity" dropdown after I select the Domain and Service dropdowns although the "Service Data JSON (optional) section appears.

Glad to do any troubleshooting for you if helpful.

cgiesche commented 9 months ago

I'm slowly going crazy:

I don't understand it.

Maybe someone who is experiencing the issue (on Windows) can check if there is an error in the debug console. Here's how to do it:

forcepd commented 9 months ago

Here is the screenshot I have after following those steps:

Screenshot 2024-01-03 155829

forcepd commented 9 months ago

Also not sure if this matters but I'm running on Windows 10

cgiesche commented 9 months ago

Here is the screenshot I have after following those steps:

Thank you! Nothing unusual to see there :/

Also not sure if this matters but I'm running on Windows 10

In this case, it does not matter. My personal verdict is, that there must be at least one "special" entity in your home-assistant, that somehow causes the problem.

Maybe, you or someone else with this issue can make this request and share the response with me: https://reqbin.com/c-2qwz2ahd

DISCLAIMER The respone contains the names, ids and current state of ALL our home assistant entities. If you do not want to share this data with the public, please attach the output to a mail and send it to me (christoph.giesche_github@cgidev.de). I will only use it to find out, if one of the enties is causing the problem and then delete this data.

After your request succeeded, it should look like this:

forcepd commented 9 months ago

Thanks. I will take a look at this later tonight and email you the output.

Note that the first time I select the entity box under keypad appearance, it appears to work correctly; i.e. I select "light" from the dropdown under Domain and then all of the lights are populated correctly under the Entity dropdown list.

codeandcats commented 8 months ago

Any updates on this? I am experiencing the same issue.

Plugin connects, displays the correct status label, but doesn't show an option for picking the entity in the keypad actions.

Interestingly, the plugin doesn't even seem to make requests for services where the entity is specified in the service data. Case in point, the following works perfectly in HA:

image

But what I believe is the same config doesn't work in the plugin:

image

Environment

OS: MacOS 14.2.1 Stream Deck: 6.4.1 (19697) Home Assistant Plugin: 2.4.2 (from Marketplace)

I'm happy to help out anyway I can with sending diagnostics but am unsure how to do so on Mac.

cgiesche commented 8 months ago

Interestingly, the plugin doesn't even seem to make requests for services where the entity is specified in the service data. Case in point, the following works perfectly in HA

Everything points to the problem being one or more entities that somehow break my code. Yesterday I installed my PC from scratch, did not use any backups and the plugin is working perfectly fine.

You can help like described above: https://github.com/cgiesche/streamdeck-homeassistant/issues/227#issuecomment-1877768549

With this data, I could import your entities in my local plugin (of course, i can not control them or view live data as this is only a snapshot) and hopefully, the error will occur.

codeandcats commented 8 months ago

@cgiesche I have a large network of devices which I'm not comfortable sharing, even with someone privately, I hope you can understand.

I do agree though that this is environmental.

May I suggest another way to approach this? If it were true that some sort of entity was causing the code not to show the list of entities and prevent requests from sending, what are the most likely places of code that would fail?

I'm unfamiliar with the codebase, Vue and Stream Deck plugins, but if I were to take a high probability stab in the dark imho... I wonder if the code is expecting a property to exist on an entity and it's accessing a sub-property/method of it but the property is undefined for a particular entity.

Some suggestions:

UPDATE

@cgiesche i have emailed you an anonymised version of my entity states.

cgiesche commented 8 months ago

I have just created a debug release which has to be installed manually (https://github.com/cgiesche/streamdeck-homeassistant/releases/tag/2.4.3). It does perform intense logging at the place where available entities are filtered after selecting a service for a button action.

You can access the logs like described in https://github.com/cgiesche/streamdeck-homeassistant/issues/227#issuecomment-1875988101.

Example output: image


You can verify, the debug release is installed correctly by rightclicking the plugin in the streamdeck app: image

codeandcats commented 8 months ago

@cgiesche Here is a screenshot of the JS console. Note that I tweaked your build slightly to just output the count of available entities and services rather than outputting the entities and services themselves.

Screenshot 2024-01-27 at 2 17 55 pm

I hope this is helpful. I also privately emailed you a screen-recording of my session if that's more helpful.

UPDATE

Best I can tell, this line of code expects selectedService.target.entity to be an array, but it can just be an object.

  if (selectedService && selectedService.target && Array.isArray(selectedService.target.entity)) {
    ...
  }

  console.log("[DEBUG] Selected service does not support target. So, no entities available :(")

...

Confirmed, changing the above code to this seemed to fix it for me! 🥳

  const targetEntities = selectedService && selectedService.target && (
    Array.isArray(selectedService.target.entity) ? Array.isArray(selectedService.target.entity) : [selectedService.target.entity]
  )

  if (targetEntities) {
    ...
  }
cgiesche commented 8 months ago

I've also just come to the same realization. Thanks for the support!

And once again, as a Java developer, I've fallen victim to the type uncertainty of JavaScript. :D Edit: To be precise, I was more a victim of Python, which generated the JSON.

Edit 2: None of my services returns a single object in target.entity. Even if there is only a single object, it is returned inside an array. This is how my climate.turn_on service looks like: '{"domain":"climate","name":"turn_on","title":"Turn on","description":"Turns climate device on.","dataFields":{},"target":{"entity":[{"domain":["climate"]}]},"serviceId":"climate.turn_on"}' Strange world.

I will create a fix release!

cgiesche commented 8 months ago

Here we go: https://github.com/cgiesche/streamdeck-homeassistant/releases/tag/2.4.4

This will hopefully be the next release for the elgato store. Besides (hopefully) fixing this issue, It contains some other minor fixes and improvements.

Please feel free to test and give your feedback.

codeandcats commented 8 months ago

And once again, as a Java developer, I've fallen victim to the type uncertainty of JavaScript. :D

Haha, well you're in good company. As a former C# (basically Java) dev myself, my advice is to embrace TypeScript! 😅

2.4.4 seems to be working as expected 👌 Thanks for your time, patience and persistence 💯 🥇