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

Fix for issue discussed in #198. #199

Merged
merged 2 commits into from
May 25, 2021
Merged

Conversation

faanskit
Copy link
Contributor

Scene device triggers were not unique from Scenes and device_trigger /config topic was too long

… unique from Scenes and device_trigger /config topic was too long
@faanskit faanskit changed the title Fix for issue discussed im #198. Fix for issue discussed in #198. May 20, 2021
Copy link
Collaborator

@SweVictor SweVictor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really very strange that these changes. The device part should not have to be unique (it IS the same device), and mqtt topic length also seems strange as a limitation...

But going from not working to working is of course a great step forward!

@faanskit
Copy link
Contributor Author

Yea, agree.
But empirical tests were conclusive. Guess a few more tests would be needed to fully conclude.
Possibly ask the devs of HA.

@SweVictor
Copy link
Collaborator

Yeah, I understand, still strange! With the working solution - can you see the device triggers somewhere in HA? Do they show up in the Logbook? Can you see a device with entity connected?

@faanskit
Copy link
Contributor Author

faanskit commented May 20, 2021

Really very strange that these changes. The device part should not have to be unique (it IS the same device), and mqtt topic length also seems strange as a limitation...

Maybe not super strange. From homeassistant/components/scene/__init__.py:

class Scene(Entity):   
 """A scene is a group of entities and the states we want them to be."""

With the working solution - can you see the device triggers somewhere in HA?

Yes, see screenshots below. Note "Model" is named Scene by you ;-)

Do they show up in the Logbook?

EDIT:
You can see automations triggered in the logbook. See screenshot.
History does not show this entity.

Device
enheter
enhetsinformation
enhetsinfo_mqtt

Entity
entiteter
entitetsinformation

History
history

Log
logg

Logentry
logentry

@SweVictor
Copy link
Collaborator

With the current develop (without this PR) I can see similar info under MQTT info under the scene which shows up under entities.

image

I also see the MQTT message come through, but no automation is triggered. Maybe it is as you say that while you can combine sensors and outputs in one device you cant combine scenes and other stuff (device triggers) in one device...

@faanskit
Copy link
Contributor Author

I also see the MQTT message come through, but no automation is triggered. Maybe it is as you say that while you can combine sensors and outputs in one device you cant combine scenes and other stuff (device triggers) in one device...

I had strange and random behavior without the patch.

Example:
Scenario: Two Plejd Scenarios (LeftOn/LeftOff), without patch:

  • Both LeftOn/LeftOff available as HA Scenarios in entity list
  • LeftOff is shown as a Device in the Device list, LeftOn is not (!?!)
  • No automations triggered when /state is sent
  • When removing LeftOff from the Ui, LeftOn appears (!!!)
  • No automations triggered when /state is sent

Example:
Scenario: Two Plejd Scenarios (LeftOn/LeftOff), only with unique-id patch:

  • Both LeftOn/LeftOff available as HA Scenarios in entity list
  • LeftOff is shown as a Device in the Device list, LeftOn is not (!?!)
  • LeftOff MQTT data is empty (!!!)

As I said, strange and random behavior.

… so that following device_automations gets executed.

This will make Plejd Scene execution behave the same from Plejd App, Plejd Hardware and Home Assistant Scene triggered - in the eyes of Home Assistant
@faanskit
Copy link
Contributor Author

Ok, I think I made a [small] mistake when I created this PR.
Every commit/pull to my development branch will now be added to this PR.
Sorry for that.

Anyway; the latest push is relevant for this PR. Please check it out. It's the feature that was not a bug wrt. Plejd Scenes from HA not being reported back to HA for automations...

@faanskit
Copy link
Contributor Author

Been looking into this trying to recreate the issues again aiming to bring the length issue to the devs of HA.
But, with a clean system, I cannot reproduce the "length" issue as a standalone issue.

My suspicion is that the "id" issue leaves some weird things in device registry causing these strange behaviors.

Nevertheless, I recommend the leave the fixes as proposed in PR as they appear to work and that I have seen weirdness with the length; even though I cannot reproduce it now.

@SweVictor
Copy link
Collaborator

Alright, merging this then. Thanks for the fix!

@SweVictor SweVictor merged commit 8f15042 into icanos:develop May 25, 2021
@SweVictor SweVictor mentioned this pull request Jun 14, 2021
@masfak97
Copy link

masfak97 commented Aug 8, 2021

If I understand it correctly, the 0.8.0-beta should make device triggers work? However, even with the 0.8.0-beta installed I can't get my automation in Home Assistant to trigger repeatedly.
When the plejd add-on is started, both my scenarios are created and visible in MQTT Explorer as a retained message with QoS 0 even though the payload says QoS 1. The automation gets triggered.

Every following time the plejd scenario gets called (double click physical switch) the original message fails to be replaced but it seems as if a message goes through on the parent topic (homeassistant/device_automation/plejd/XXXX_trig/ instead of homeassistant/device_automation/plejd/XXXX_trig/config). Sometimes the message is retained but still can't be replaced.

If I delete the entire message in MQTT explorer and then double-click, an empty message is created with topic homeassistant/device_automation/plejd/XXXX_trig/state. After that, for each double-click, the empty message is deleted and created.

If I restart the plejd add-on, the messages are recreated and the automation triggers once.

Do you have any ideas on what to do? I would really like to be able to trigger HA automations with Plejd scenes.

@masfak97
Copy link

Found another thread discussing this and will answer my own question. Triggering an automation by an MQTT PLEJD automation trigger in HA isn't done by reacting to the MQTT message, rather using the created device with the same name as the scenario in the PLEJD app as a trigger. This works fine for me.

@faanskit faanskit deleted the develop branch December 12, 2021 15:39
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.

3 participants