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

Support for states on EntityCommands, Monitor entity as a switch with state topic #29

Closed
wants to merge 3 commits into from

Conversation

infeeeee
Copy link
Collaborator

With this changes it's now possible to set a state for an EntityCommand, and publish it. In HomeAssistant Switches can show up as a real switch, with correct states. https://www.home-assistant.io/integrations/switch.mqtt/#state_topic

I implemented first for the Monitor entity. Unfortunately on windows you cannot get the states of the monitors, so this only works on linux, with X11. In HA for Windows machines, there is one switch now, with ON and OFF buttons, so only one line on the UI.

Tested on both Windows and Linux.

@richibrics
Copy link
Owner

Hi @infeeeee,
Sorry for the absence, but it is the period of the exam session and I am a bit busy.
I like the idea to set a value to commands.
I'm not really convinced on how you implemented them: in this way we are using commands data entity as an extension of the sensors data entity, while I wanted to have them separately.
PS: I also worked on a csv warehouse where sensors data can be saved but in this way I should also add switches.

What do you think if I take your solution but editing it in this way: command data entity will take an optional key of a command entity sensor, so when the value is edited to the sensor, it's sent like in your solution as state of the command.

In case you didn't understand I could be more clear.
Bye

@richibrics
Copy link
Owner

In this way, warehouses that do not support switches/switches with value, can simply use the sensor to take the value

@infeeeee
Copy link
Collaborator Author

Ok, I understand what you are saying, so there should be a separate Monitor command and a Monitor sensor, and only combine them in the Homeassistant and MQTT warehouse, where it makes sense to combine them, and use the same topic as state and command. I like this approach!

I will close this and create a new PR, and cherrypick commits from here, as this requires a lot of changes, and this branch now contains a lot of unnecessary changes.

Considering #34 #35 #36:

It think they should be separate from this Monitor command, as ExternalDisplay or DisplayConfiguration or something, and they could be displayed as a Select Entity in HomeAssistant:

@infeeeee infeeeee closed this Jan 10, 2023
@richibrics
Copy link
Owner

Exactly (not two different entity but the sensor data and command data in the same entity, just to be sure we're on the same idea).

I totally agree to add a different entity for the configurations.

@richibrics
Copy link
Owner

Also the Select entity in Hass would be so nice ! Great idea

@infeeeee
Copy link
Collaborator Author

Exactly (not two different entity but the sensor data and command data in the same entity, just to be sure we're on the same idea).

I see now, I should use both self.RegisterEntityCommand() and self.RegisterEntitySensor() on init stage.

@richibrics
Copy link
Owner

Yes, but the link to the Sensor from the Command is not ready yet.

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.

2 participants