w-floyd / ha-mqtt-iot Goto Github PK
View Code? Open in Web Editor NEWA simple configurable MQTT client that allows actions to be taken or values be reported from a PC
License: MIT License
A simple configurable MQTT client that allows actions to be taken or values be reported from a PC
License: MIT License
Perhaps it's just my system, but it does not update. I think it is reporting the average since boot?
Edit: If I run mpstat 1
it reports the correct statistics over time. It is running it a single time that is problematic.
Using mpstat 1 1
works
Line 163 in 788db77
This used to be a thing ages ago (I had battery status, backlight, that come to mind). I want to redo this and extend it to more cases, such as:
Ideally, we should not implement all of these things ourselves, and certainly not in this repo - if we need to, it might make sense to create an external library that may provide all of this information. I am sure this is something we can find elsewhere.
Released as of HA 2022.11
Lines 22 to 25 in 788db77
Specifically, KDE and Gnome are my targets, though contributions are welcome for any others.
Trying this on an embedded system (router) that does not have /etc/machine-id
, the program fails.
Primarily GNOME and KDE, though others are welcome. Testing also with X11 and Wayland.
X11 | Wayland | |
---|---|---|
GNOME | ||
KDE | ||
XFCE | ||
Budgie | ||
Cinnamon | ||
LXQT |
I think it should be possible to do hack our way into this pretty easily at the moment, but it would require some fiddling with topics and such. Instead, I propose that I change to a model of commands generating a single topic output, which we can then reference easily per-device. For example, nvidia-smi
has a ton of great data, but we currently have to probe it multiple times. Why not re-use this output? For example, we could create a topic of /ha-mqtt-iot/<deivce>/state/gpu/0
which will carry a full JSON output of what we want, and then use value_template
on many entities to derive all the sensors we want. Probe once, post once, just tell HomeAssistant where to look.
In cases where we don't have more than one entity as a result of a command, we can still use the same format - keep it simple. Topic generation needs to be automatic.
A first thought at this is to name a command in one place, and reference it per entity - so each place we currently allow providing a function would now be a reference.
DEBUG[client] Connect()
DEBUG[store] memorystore initialized
DEBUG[client] about to write new connect msg
DEBUG[client] socket connected to broker
DEBUG[client] Using MQTT 3.1.1 protocol
DEBUG[net] connect started
DEBUG[net] received connack
DEBUG[client] startCommsWorkers called
DEBUG[client] client is connected/reconnected
DEBUG[net] incoming started
DEBUG[net] startIncomingComms started
DEBUG[net] outgoing started
DEBUG[net] startComms started
DEBUG[pinger] keepalive starting
DEBUG[client] startCommsWorkers done
DEBUG[client] exit startClient
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] startIncomingComms: inboundFromStore complete
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] outgoing waiting for an outbound message
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/binary_sensor/ha-mqtt-iot/work-mode-paused-desktop/config
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/binary_sensor/ha-mqtt-iot/work-mode-desktop/config
DEBUG[net] obound msg to write 0
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/switch/ha-mqtt-iot/dark-mode/config
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/sensor/ha-mqtt-iot/work-duration/config
DEBUG[client] enter Publish
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[client] sending publish message, topic: homeassistant/switch/ha-mqtt-iot/desktop-monitor-awake/config
DEBUG[net] obound msg to write 0
DEBUG[client] enter Publish
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[client] sending publish message, topic: homeassistant/sensor/ha-mqtt-iot/work-started/config
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] incoming complete
DEBUG[net] startIncomingComms: got msg on ibound
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] startIncomingComms: ibound complete
DEBUG[net] startIncomingComms goroutine complete
DEBUG[net] outgoing waiting for an outbound message
ERROR[client] Connect comms goroutine - error triggered EOF
DEBUG[client] internalConnLost called
DEBUG[client] stopCommsWorkers called
DEBUG[client] startCommsWorkers output redirector finnished
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] outgoing comms stopping
DEBUG[pinger] keepalive stopped
DEBUG[client] stopCommsWorkers waiting for workers
DEBUG[net] startComms closing outError
DEBUG[router] matchAndDispatch exiting
DEBUG[client] stopCommsWorkers waiting for comms
DEBUG[client] comms goroutine done
DEBUG[client] internalConnLost waiting on workers
DEBUG[client] stopCommsWorkers done
DEBUG[client] internalConnLost workers stopped
DEBUG[client] internalConnLost complete
DEBUG[client] enter reconnect
DEBUG[client] about to write new connect msg
DEBUGConnection lost: EOF
DEBUG[client] socket connected to broker
DEBUG[client] Using MQTT 3.1.1 protocol
DEBUG[net] connect started
DEBUG[net] received connack
DEBUG[client] startCommsWorkers called
DEBUG[client] client is connected/reconnected
DEBUG[net] incoming started
DEBUG[net] startIncomingComms started
DEBUG[net] outgoing started
DEBUG[net] startComms started
DEBUG[client] startCommsWorkers done
DEBUG[store] enter Resume
DEBUG[store] exit resume
DEBUG[pinger] keepalive starting
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] startIncomingComms: inboundFromStore complete
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] outgoing waiting for an outbound message
DEBUG[client] enter Publish
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/sensor/ha-mqtt-iot/work-started/config
DEBUG[net] obound msg to write 0
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/binary_sensor/ha-mqtt-iot/work-mode-paused-desktop/config
DEBUG[client] sending publish message, topic: homeassistant/sensor/ha-mqtt-iot/work-duration/config
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/binary_sensor/ha-mqtt-iot/work-mode-desktop/config
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/switch/ha-mqtt-iot/dark-mode/config
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[client] enter Publish
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[client] sending publish message, topic: homeassistant/switch/ha-mqtt-iot/desktop-monitor-awake/config
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] incoming complete
DEBUG[net] startIncomingComms: got msg on ibound
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] startIncomingComms: ibound complete
DEBUG[net] startIncomingComms goroutine complete
DEBUG[net] outgoing waiting for an outbound message
ERROR[client] Connect comms goroutine - error triggered EOF
DEBUG[client] internalConnLost called
DEBUG[client] stopCommsWorkers called
DEBUG[client] startCommsWorkers output redirector finnished
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] outgoing comms stopping
DEBUG[router] matchAndDispatch exiting
DEBUG[net] startComms closing outError
DEBUG[pinger] keepalive stopped
DEBUG[client] comms goroutine done
DEBUG[client] stopCommsWorkers waiting for workers
DEBUG[client] stopCommsWorkers waiting for comms
DEBUG[client] stopCommsWorkers done
DEBUG[client] internalConnLost waiting on workers
DEBUG[client] internalConnLost workers stopped
DEBUG[client] internalConnLost complete
DEBUGConnection lost: EOF
DEBUG[client] enter reconnect
DEBUG[client] about to write new connect msg
DEBUG[client] socket connected to broker
DEBUG[client] Using MQTT 3.1.1 protocol
DEBUG[net] connect started
DEBUG[net] received connack
DEBUG[client] startCommsWorkers called
DEBUG[client] client is connected/reconnected
DEBUG[net] incoming started
DEBUG[net] startIncomingComms started
DEBUG[net] outgoing started
DEBUG[net] startComms started
DEBUG[pinger] keepalive starting
DEBUG[client] startCommsWorkers done
DEBUG[store] enter Resume
DEBUG[store] exit resume
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] startIncomingComms: inboundFromStore complete
DEBUG[net] logic waiting for msg on ibound
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/binary_sensor/ha-mqtt-iot/work-mode-paused-desktop/config
DEBUG[client] enter Publish
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/switch/ha-mqtt-iot/dark-mode/config
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/switch/ha-mqtt-iot/desktop-monitor-awake/config
DEBUG[client] enter Publish
DEBUG[client] sending publish message, topic: homeassistant/sensor/ha-mqtt-iot/work-started/config
DEBUG[client] sending publish message, topic: homeassistant/sensor/ha-mqtt-iot/work-duration/config
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[client] enter Publish
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[client] sending publish message, topic: homeassistant/binary_sensor/ha-mqtt-iot/work-mode-desktop/config
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] obound msg to write 0
DEBUG[net] obound wrote msg, id: 0
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] incoming complete
DEBUG[net] startIncomingComms: got msg on ibound
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] startIncomingComms: ibound complete
DEBUG[net] startIncomingComms goroutine complete
DEBUG[net] outgoing waiting for an outbound message
ERROR[client] Connect comms goroutine - error triggered EOF
DEBUG[client] internalConnLost called
DEBUG[client] stopCommsWorkers called
DEBUG[client] startCommsWorkers output redirector finnished
DEBUG[pinger] keepalive stopped
DEBUG[net] outgoing waiting for an outbound message
DEBUG[client] stopCommsWorkers waiting for workers
DEBUG[router] matchAndDispatch exiting
DEBUG[client] internalConnLost waiting on workers
DEBUG[client] stopCommsWorkers waiting for comms
DEBUG[net] outgoing waiting for an outbound message
DEBUG[net] outgoing comms stopping
DEBUG[net] startComms closing outError
DEBUG[client] comms goroutine done
DEBUG[client] stopCommsWorkers done
DEBUG[client] internalConnLost workers stopped
DEBUG[client] internalConnLost complete
DEBUGConnection lost: EOF
DEBUG[client] enter reconnect
DEBUG[client] about to write new connect msg
DEBUG[client] enter Publish
DEBUG[client] enter Publish
DEBUG[client] enter Subscribe
2020/10/23 03:36:56 not currently connected and ResumeSubs not set
mpstat is a part of this
Lines 18 to 21 in 1902782
The following message keeps appearing, looping
DEBUG[net] logic waiting for msg on ibound
DEBUG[net] startIncomingComms: got msg on ibound
DEBUG[net] startIncomingComms: received publish, msgId: 0
DEBUG[net] startIncoming Received Message
with a config of:
"lights": [
{
"info": {
"name": "Desktop Monitor",
"id": "monitor"
},
"command": [
"./scripts/monitor.sh",
"command"
],
"command_state": [
"./scripts/monitor.sh",
"command-state"
],
"command_color_temp": [
"./scripts/monitor.sh",
"color-temp"
],
"command_color_temp_state": [
"./scripts/monitor.sh",
"color-temp-state"
],
"command_brightness": [
"./scripts/monitor.sh",
"brightness"
],
"command_brightness_state": [
"./scripts/monitor.sh",
"brightness-state"
],
"brightness_scale": 100,
"update_interval": 5
}
],
I don't even know how this would need to be designed at the moment, but it is something we should do to allow hotplugging support.
Consider adding builtin for computer fans?
Got added in 2022.12, should be pretty simple up add to the helper, and is actually a really good use case for this tool.
Should be simple, adding a option to the config to load an cert file.
Being able to push data to this tool would improve latency/reduce polling, and allow more complicated tools to be decoupled much easier. I am not a computer scientist, so my immediate thought is to allow using a Unix socket (if available?), or maybe just a file to write the state to. Any accompanying program would then watch the state to take commands.
When I suspend and later resume my computer it loses connection to the MQTT server and doesn't attempt to reconnect. I need to restart the app manually.
I see this error:
ERROR [client] Connect comms goroutine - error triggered read tcp 192.168.1.52:46248->192.168.1.45:1883: read: connection reset by peer
These processes will show as using the camera. This is likely going to be the case moving forward, especially under Wayland. This present a challenge, as we may instead need to check Pipewire for camera status instead.
While I have reasonable confidence that most simple device types will work, I expect there to be issues in the more complicated device types. I will consider a device validated when I have an example in the sample config. Further validation will be required in future, this is just a first pass.
As of 2023.08, code generation is broken (slice out of bounds). Need to check what is broken exactly, likely config block is changed in a file.
As I found for device_tracker
, the layout was a bit weird with the old config being parsed as new. I need to check all of the devices.
Possibly add builtin for sending periodic screen captures.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.