Current sensor to show state of lamp and be able to trigger the switch On or Off

I put it in a folder called /mqtt in my /home directory. You can put it anywhere as long as you tell the program where the config file is when you execute it: GitHub - flyte/mqtt-io: Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.

did not use the virtual environment install…
did everything as above and updated just the pip3 from the correct location command and the error was gone.

Rebooted and ran the service and it ran and everything works flawless and seamless I was definitely missing out all along and can most definitely say this is by far the most relaible and seamless sensor detection method I have tried thus far. I have tried a HA instance with my sensors directly connected to Gpio on that Pi, then tried HA with a remote connected pi with sensors directly connected to Gpio on the remote pi and I have even tried Gpio2 custom components. I was never able to get reliable detection with any of them and I have spent quite some time tinkering in each method trying to make sure everything was done correctly and properly.

With everything and all the help I have received thus far is seems I always have another hurdle to cross and its now trying to get the systmd method to auto run the service on t reboot…I am getting a option to enable root or pi requiring a manual feedback. I guess python and tinkering remains my area of greatest challenge sigh.
but progress as slow as it may be is still progress and I appreciate all the assistance thus far

I have the same problem with my remote system sensor monitoring for the pi. Never solved it. If you are interested in monitoring your remote pi cpu memory etc this is a good option with discovery: Remote RPI system monitor

However I restart it so rarely that I’ve actually had to write down the startup instructions because I forget them in the intervening time (year+).

I never ended up using the virtual environment install method. Instead I was directed by some really smart guys to do the following and I hope it helps anyone here.
I defined the python environment following this

The versions numbers will of course have to be changed to the ones your system has and then the latest version set as default ( auto) in the whole system

Do an install for user pi

pip install pi-mqtt-gpio

create the config.yaml file

then for system wide

sudo -i
pip install pi-mqtt-gpio

create script file for run on startup using init.d method
nano /etc/init.d/mqtt.sh

-----insert the following------

#!/bin/bash
### BEGIN INIT INFO
# Provides:          sample.py
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     S 2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO
sleep 5s
/usr/bin/python3 -m pi_mqtt_gpio.server /home/pi/config.yaml >> /var/log/mqtt_server.log 2>&1 &

then

sudo reboot

the sleep time of 5 sec was added to allow for any services that was not available on boot. When we used zero seconds service fails.

I asked anilet for some feedback on his system which uses master/ slave HA instances for additional implementation of room sensors with mqtt gateway but I know you already hooked on esp home.
Care to share any reasons why you opted for this method?

and any responses to the question I asked peter

thanks again