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

Add container host to MQTT events #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mscottco
Copy link

Hope it's okay to open a pull request against your repo. This change is to add the container host to the MQTT events so it appears as an attribute in Homeassistant so its a bit easier to tell which containers are running where...

@miaucl
Copy link
Owner

miaucl commented Dec 19, 2024

Hope it's okay to open a pull request against your repo. This change is to add the container host to the MQTT events so it appears as an attribute in Homeassistant so its a bit easier to tell which containers are running where...

Not sure why you would need this info in the event? The discovery topic should already contain the relevant information and can be used to identify the server. I'd prefer to avoid adding data to the event, which is redundant and just increases bandwidth for mqtt.

@miaucl
Copy link
Owner

miaucl commented Dec 19, 2024

Information available in the discovery topic

{"name": "CPU", "unique_id": "docker_homeserver_homeassistant/sensor/docker/homeserver_docker2mqtt_cpu_stats/config", "availability_topic": "docker/homeserver/status", "payload_available": "online", "payload_not_available": "offline", "state_topic": "docker/homeserver/docker2mqtt/stats", "value_template": "{{ value_json.cpu if value_json is not undefined and value_json.cpu is not undefined else None }}", "unit_of_measurement": "%", "icon": "mdi:chip", "device": {"identifiers": "homeserver_docker_docker2mqtt", "name": "homeserver Docker docker2mqtt", "model": "Linux x86_64 Docker version 27.2.1, build 9e34c9b"}, "qos": 1}

What is your usecase which is not covered by this?

@mscottco
Copy link
Author

mscottco commented Jan 5, 2025

Thanks, Totally understand wanting to keep the MQTT payloads light.

The main use case is that I've got the entities fed into a flex-table-card in homeassistant and it's useful to be able to sort+filter based on the host they're running on. I agree the data is in the friendly_name of the entity but its not an easy or clean field to present the data with.

miaucl
miaucl previously approved these changes Jan 6, 2025
Copy link
Owner

@miaucl miaucl left a comment

Choose a reason for hiding this comment

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

This is reasonable I guess :)

@miaucl
Copy link
Owner

miaucl commented Jan 6, 2025

@mscottco Please check with the workflows that the types are correctly set.

docker2mqtt/type_definitions.py Outdated Show resolved Hide resolved
@miaucl miaucl self-requested a review January 21, 2025 05:38
Copy link
Owner

@miaucl miaucl left a comment

Choose a reason for hiding this comment

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

Did you run the mypy task locally in your repo?

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