ironsheep / RPi-Reporter-MQTT2HA-Daemon

Linux service to collect and transfer Raspberry Pi data via MQTT to Home Assistant (for RPi Monitoring)
GNU General Public License v3.0
475 stars 64 forks source link

Should {hostname} be replaced with hostname? #131

Open pskowronek opened 10 months ago

pskowronek commented 10 months ago

Checklist:

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:

  1. the hostname was not found and was not replaced
  2. I should have replaced {hostname} in config.ini with real name (it is not so obvious)
  3. the log shows topic before evaluation of the placeholder and there's nothing to worry about

Expectations:

pskowronek commented 10 months ago

obraz

When I leave {hostname} in configuration. Still I don't know if it should be replaced automatically, or I should edit that.

bsimmo commented 10 months ago

In the config.ini you create.

This

The MQTT name for this Raspberry Pi as a sensor

sensor_name = rpi-{hostname}

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.

You only un-comment that and alter the hostname to give it something different to the default or if it is not working. Change rpi-{hostname} to whatever you want, this is the sensor name not the actual hostname you are changing. It is there as some people wanted deb-{hostname} or ubuntu-{hostname} or even Sillysensoratrpi{hostname}devicething

On Sun, 28 Jan 2024, 3:45 pm Piotr Skowronek, @.***> wrote:

obraz.png (view on web) https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/assets/360665/d6515fac-b445-4a4c-929f-7c830dddcb71

When I leave {hostname} in configuration. Still I don't know if it should be replaced automatically, or I should edit that.

— Reply to this email directly, view it on GitHub https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/issues/131#issuecomment-1913639184, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYAXN2F4YKAG46NPAVE2P3YQZXADAVCNFSM6AAAAABCNY2UECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGYZTSMJYGQ . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>

bsimmo commented 10 months ago

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

fallbackdomain = home

Remove the # and change home to whatever you want.

pskowronek commented 10 months ago

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 #fallbackdomain = 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 .

bsimmo commented 10 months ago

You'll see some other topics/pulls that are open that do just this or talk about it, I have just commented to a few just now so you can see some. #122

126 So you're not the only one.

Feel free to edit and make a pull request, though there are a few good ones waiting already, #126 #106 @ironsheep seems to be busy, away, working things out.

Remember this is his project for something he wanted, everything else is a bonus and tagged on for others :)

Given that change is not talked about in the normal setup, it's really an advanced setup. Maybe an advanced setup/wiki page needs creating for the other options. and linked to from ironsheep/RPi-Reporter-MQTT2HA-Daemon: Linux service to collect and transfer Raspberry Pi data via MQTT to Home Assistant (for RPi Monitoring) (github.com) https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon?tab=readme-ov-file#configuration ?


I was unsure if you had fixed the hostname on the one not working, hence you were editing the config.ini to try fix it, just the wrong bit.

On Sun, 28 Jan 2024 at 17:37, Piotr Skowronek @.***> wrote:

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 .

— Reply to this email directly, view it on GitHub https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon/issues/131#issuecomment-1913670391, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYAXNYT52DTPX5XRIMMGL3YQ2EHJAVCNFSM6AAAAABCNY2UECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGY3TAMZZGE . You are receiving this because you commented.Message ID: @.***>

pskowronek commented 10 months ago

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.