joshuar / go-hass-agent

A Home Assistant, native app for desktop/laptop devices.
MIT License
117 stars 8 forks source link

[FEATURE REQUEST] Opt-Out of Sensors and Agent Side Command Definitions #171

Open cmprmsd opened 1 month ago

cmprmsd commented 1 month ago

Hey there!

  1. Would it be a lot of effort to make the built-in sensors configurable, so that I may turn off everything I don't need? That would lower power consumption and save resources.

  2. I tried adding turn screen off and on with dpms without locking the screen for my info panel and this was quite complicated as I had to write a python script that registers a new dbus service in order to use the arbitrary dbus PR that was merged recently. Of course I had to configure two buttons in the scripts configuration of hass in order to publish the according mqtt messages. Wouldn't it be nice to parse a commands.toml on the agent side where we can define commands and on launch the agent will register e.g. buttons or switches with ways to execute commands for each state of the switch. This could be enhanced with "query state" so that we could e.g. read if the monitor is really turned of or on.

I could fiddle with the code a bit but I'm more the offensive person who searches for vulns in apps. šŸ˜‚ What do you think of the ideas?

joshuar commented 1 month ago

Hey thanks for trying out the agent!

Indeed, currently there is no way to disable the sensors in the agent. However, you can disable the sensor entities in Home Assistant, and the agent will then stop sending updates for them. It won't stop gathering the data, so this is probably only half the solution you are looking for. I would like the ability to customise which sensors are enabled in the agent, so look out for a full solution in a future release :smile:

I really like the idea of custom commands, that complements the existing custom sensors that are already supported. So is the idea, for a button:

That's cool. It might need a little more configuration for a switch and other types, as the switch would probably need a way to get the current state and a way to change the state between two values. That could just be a few different command-line switches for the script though.

joshuar commented 1 month ago

Hey there. So v9.4.0 contains initial support for custom commands, though you will need Home Assistant and the agent configured with MQTT support. For the moment, just buttons are supported, but I intend to add switches (on/off) and number support. Check out the README for details on configuration and usage.

Having the ability turn on/off sensors is still a way away, but I've refactored some code to make this closer to reality. Look out for it in a future release!

cmprmsd commented 4 weeks ago

Amazing! Looks very promising! šŸ˜Š