Should {hostname} be replaced with hostname?
pskowronek opened this issue · 6 comments
Checklist:
- I updated to the latest version available
- I checked that my MQTT broker is otherwise working
Release with the issue:
2024.01.28 master
Last working release (if known):
N/A
Hardware, Operating System, Python version:
RPi zeros, Raspbian 11
Description of problem:
I've tried to setup this project on 3 RPi I got - 2 had no problem displaying their name (hostname -f
), 1 had such a problem. However, to be sure in config.ini
I set fallback to their names.
When running systemctl status
I see for all of them the following:
systemctl status isp-rpi-reporter.service
● isp-rpi-reporter.service - RPi Reporter MQTT Client/Daemon
Loaded: loaded (/opt/RPi-Reporter-MQTT2HA-Daemon/isp-rpi-reporter.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2024-01-28 00:59:41 GMT; 2s ago
Docs: https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon
Main PID: 28680 (python3)
Status: "Jan 28 00:59:40 - * NOTIFY: on_message() Topic=[home/rpi-nodes/command/rpi-{hostname}/status] payload=[b'offline'] command=[status]."
Tasks: 4 (limit: 414)
CPU: 13.648s
CGroup: /system.slice/isp-rpi-reporter.service
└─28680 /usr/bin/python3 -u /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-daemon.py
In Status line I see "rpi-{hostname}" - is this correct? I mean, since this is my first setup with this project, I had the following doubts:
- the hostname was not found and was not replaced
- I should have replaced {hostname} in config.ini with real name (it is not so obvious)
- the log shows topic before evaluation of the placeholder and there's nothing to worry about
Expectations:
- I think in status (logs) one should see the final result
- example
config.ini.dist
should have additional explanation abovetopic
that {hostname} will be replaced with a proper hostname (using fallback if required) - If there was a problem with hostname resolution, the topic nor the name should not contain
no_address_associated_with_hostname
, but something likefqdn-unknown
orfqdn-unknown-IP
(where IP is the IP :) ). The sensor name looks like this (even if I fixed the problem hostname resolution /I guess I need to reset sth and re-add it to HA):sensor.rpi_my_raspberrypi_rpi_monitor_hostname_no_address_associated_with_hostname
. And btw, why hostname is present in two times in entity name (on the beginning and at the end)?
Are you using RaspberryPi OS from RaspberryPi.com / Pi Imager or some other version of it?
PiOS '11' is Bullseye so should just work.
Hostname it retrieved from
/bin/hostname -f
If that doesn't work, try fix that.
If you cannot then you change
# default domain to use when hostname -f doesn't return a proper fqdn
#fallback_domain = home
Remove the # and change home to whatever you want.
Are you using RaspberryPi OS from RaspberryPi.com / Pi Imager or some other version of it?
I have bullseye RaspberryPi OS.
PiOS '11' is Bullseye so should just work.
Hostname it retrieved from /bin/hostname -f If that doesn't work, try fix that.
I've already mentioned that I've fixed the problem with hostname -f
.
If you cannot then you change # default domain to use when hostname -f doesn't return a proper fqdn #fallback_domain = home
The comment in config.ini.dist
above sensor_name
should better state this:
"Should be left as is with the # to have it ignored in the program and send
the hostname the Pi itself has been given by you. "
Otherwise one may think that sensor_name = rpi-{hostname}
must be un-commented, and {hostname} will be replaced in runtime either by hostname or fallback_domain
.
Remove the # and change home to whatever you want.
Thanks. But what I aim here is to make this behavior more obvious - both in README.md (installation part) and in config.ini.dist
.
Remember this is his project for something he wanted, everything else is a bonus and tagged on for others :)
Yup, and this is very great project! I've already submitted 2 PR to it to make it more easier to use :)
First I wanted to see whether {hostname} should be dereferenced or not. I see those PR you have mentioned @bsimmo - Let's wait for PR review. Personally I would add better comments to config.ini.dist
to explain the behavior and what's the default.
Maybe let's keep this "bug" open so it could be discussed how to make it more obvious how to use it.