Getting frustrated How to get HA to discovery a Raspberry Pi

Again, I am not trying to discourage you from pursuing your project with RPI/HA and so on. But, in my assessment (assuming I understand your situation), I think the smart plugs are way better. To start, you should download the KASA App (on iOS or Android), and play a bit with it. It has basic automation (i.e. start/stop at given times) and more advanced features, like schedules/scenes, … etc. If such automation is not sufficient, then you can integrate in HA. In fact, I can control many plugs in my home from my phone, with both iOS HA and KASA.

Now, there are many smart-plugs available out there and many companies make them, including Amazon. I prefer TP-Link as they’ve been on the market for a while and are pretty reliable. Also, check your local Costco, they might have some made by Feit, and those tend to be much cheaper.

If you want to stay with TP-Link, there are many options. The latest model is KP115, which looks exactly the same as HS-105, but in addition has energy monitoring. With the KP115, you can tell how much power the specific device is consuming.

The amazon.ca website lists the HS103 smart-plug for CDN $12.99 … which is pretty good in my book. Make sure the plug’s rating (10 Amps) is sufficient for the pumps you’re running. Otherwise, the HS105 (15 Amps version) is what you need, but the price becomes very high ($44.95). I am not sure why prices are much higher in Canada ???

Now, if you want the KP115 (has energy monitoring), check BLT Sales, it’s a web store, and they sell them for US $22.00 each. Make sure they can ship to Canada and whatever customs/duties apply.

https://www.amazon.ca/Kasa-Smart-Wi-Fi-Plug-TP-Link/dp/B079B7SHD8/ref=sr_1_10?dchild=1&keywords=smart+plug&qid=1609705086&sr=8-10

Can you check if you can buy directly from Amazon.com? … I did buy few items even from amazon.fr, and yet I live in the US.

Now, given your situation (15 Amps requirement), then try your local Costco.

If you’re feeling brave and can do electrical wiring, you can also change the outlets in your home, and use the following. It’s also made by TP-Link, but once installed it can’t be moved around. The price is very attractive as well. Do you have power outages where you live? If so, make sure the outlet and/or smart plug you use restarts to whatever status it was in before the outage. Some earlier TP-Link models always reverted to ‘off’ status. The new ones (HS105/KP115) revert to whatever status they were before the outage.

https://www.amazon.ca/Smart-Power-Outlet-2-Sockets-TP-Link/dp/B07N3CK3MM/ref=sr_1_15?dchild=1&keywords=smart+plug&qid=1609705980&sr=8-15

All of this sounds a bit complicated, but in the long run, it’s a more robust solution, and relatively affordable. Also, here in the US there have been reports that the amazon-branded smart-plugs caught fire for some customers. I would stay away from those.

So, your options:

  1. TP Link Smart Plug KP115 - Check BLT Sales - Ask for price/shipping/customs (expensive but portable)
  2. TP-Link Smart Outlet KP200 - Amazon.ca - Very good price but you need to change your outlets.

ah ok ya in canada things are high priced always its ridicules… i will dabble more… lik my setup works perfectly fine without HA i figured i could incoporate it easilly but its seemed to be more of a headache. like i thiought that GarageQpi would have worked… but wouldnt install right for the raspberry pi 4… but maybe i should have tried a clean install nothing on it… but i only got so far till i got like 404 errors etc doing the steps

but ya like works fine no HA but glitchs running but guess its not perfected yet…
tthere was a 3 pack i wanted to try at home depot but due to bigger lock downs here in ontario you cant go into the store and it was in the xmas section and u cant order it online… wanted to try that 3 pack for 20 bucks…
but ill try a random one from amazon… our costco doesnt have that least the one we at …

but i figured i could just add HA features and no issues i was wrong… ill read up on that kasa smart wifi plug… how reliable are these do they burn out etc… like i remember u needed a hub the nest and here its over priced so i never got into it … was never cheap enough to even say ill give it a shot

ok ill see about the kp200 ya that could work

has the TP ones ever failed? as i know the TP wifi switch/router i had bad luck with those

The TP-Link works with the KASA App via WIFI (no need for a hub). I’ve never had an issue with them. If your local depot has them, then by all means. They should offer curb pick-up (?).

True, in the past TP-Link had some ‘iffy’ hardware, but their quality has improved quite a bit. I’d pick them over other major contendors (such as Wemo, Belkin, …)

Yeah, I lived in Canada for few years in Toronto/Waterloo … gorgeous country though, but a bit expensive, especially if you have demanding hobbies. Was talking to a friend there few days back and he mentioned the lock-down, especially when you get closer to Toronto. It’s a pity, but somehow we’ll make it … or die trying as they say.

Good luck in your endeavour, and let us know what you find out.

Also, there is a relatively ‘new’ company with very affordable hardware: Wyze … they make $20 cameras, sprinkler controller, light bulbs, door switches … but their integration with HA is not there yet. I know HomeDepot sells their cameras, though if interested, wait a bit as they have a new camera coming out (v3), and it’s much better than the v2.

Yeah, I only bought the Nest thermostat … and got a rebate from the utility company. Everything else from Nest is very pricey, especially the cameras.

My 0.02 cents on this is: This Home Automation is still a very young/dynamic field. There is no point in investing in specialized hardware if one is not sure the hardware/protocols etc are still going to be valid tomorrow. So, but ‘affordable’ components, learn about them, and be mindful of what tomorrow brings. The last thing I want is to buy a $300 Nest camera that won’t integrate with anything else.

ya home depot has curb side. when i wanted to get the 3 pack from the Xmas section they said sorry you gotta order on website first… but of course xmas section isnt on the website… so cant order and they packing up xmas when i was there … and only till lock down is lifted but since we getting more then 3000 cases a day now in ontario lock downs gonna be a while im sure lol

well i have no issues switching from Raspberry Pi to HA i was just trying my best to intergrate it easilly but it doesnt like to work together … i tried googling if HA had a feature of Outdoor timer… so then i could tell the plug to run schedule… my question to you then if the Plug is live so running a Pump if you reboot HA does it shut off the plug like turn off a Light… or cant it keep the state it was left at… ya i live 2.5 hours east of toronto i and my son survived cancer myself twice… i was supposed to goto toronto for surgery 4 of them last 2020 and checkups with how toronto people disregarding things partying in storage lockers of 100 people or in night clubs with windows blacked out… they ruin it for people like me i only in 40s and need check ups and surgery i cant get … i just hope no cancer growing… because there drinking is more important then my surgery…

but ya ill try to get something… and try… i had the raspberry pi and setup before i got involved with home assistant and the Wifi stuff was soo expensive here… i just stayed with the raaspberry pi… but now i trying more of this HA and amazon has been popular to me as of 2020 lol…

so ill try to get one of those TP-Links and test it ill try to order one tonight and ill recheck back to ya or in this thing if i stuck or a new article… ill let u know… cuz i liked home automatiion back in 1999 2000 i was going to take it in college but my college decided wasnt popular and cancelled it… here in Peterborougg Fleming College… so i never took it… maybe id have been a better home automation guy…

i appreciate the help so far…

ya it doesnt seem to be a 1 standard protocol… and ya the nest theromostat is over 200 bucks at home depot last time i looked…

and i always ebelieved in wired home automation over wireless… how do you protect yourself from hackers sending DOSS attacks to your wifi like those people with the cameras or the door locks they showed on market place how they can jam your wifi and unlock your doors… how does one protect yourself really. as they showed hiding your SID doesnt matter they can find it… is there techniques protocols other then changing password that proects ur stuff

Yes, it seems we both started a long time back. I did about 20 years ago … with x10. We needed a camera for the baby room back then, and there was not much available back then, came x10 and the many ‘gadgets’ they had. You and I have an appreciation as to what the technology was and how it evolved.

That reminds me of a little story back around 2004 … We were in a meeting at work, and my boss back then, from a certain European country asked a question about a webcam he has just purchased. So, I replied, does it have built-in sound or it needed an external microphone? He replied in a very condescending tone: What, they make webcams without sound? What do people use to communicate, sign language? I looked at him in disbelief and chose to not even bother answering/explaining… In my mind … I wanted to throw so many insults at him, but I choose to let him bask in his arrogance.

In any event, this field is a lot of learning, and what will work for you and I is very dependent on the hardware for sure, and most importantly the skills we bring (or we’re lacking). In the end it’s a bit of a rewarding experience. I rewired many switches in my home to use smart wifi dimmers. I thought I understood the basics of electrical wiring … I was in for a surprise, and lots of learning. Of course, and needless to say, the wife does not understand nor cares about this … but it’s ok. This hobby is about learning, asking questions, debating ideas, and making friends.

So my friend, all the Very Best to you on this adventure, and may 2021 bring good health, happiness, and fortune.

PS. Let us know once you’ve got this working … always curious.

The integration you keep linking is for a RPi that has your home assistant running on it, locally. Your rpi does not have HA on it, you need the remote RPi integration which I linked you to, which you seem to be calling in your configuration.yaml, but you have not set up the two machines to talk to each other. That is why it says the sensors are not available. It won’t show up like the integrations you are looking at, but the binary_sensors and
switches will. If you follow the instructions I gave you it will work, I have the same setup working for years with no issues.

so i confused… i followed the remote GPI i orginally posted the link first message


thats why my code says binary_sensor:
  • platform: remote_rpi_gpio

so which link do i need to follow/ what are your steps again…
as i done the local mqtt where you load up to 2 windows and they work

and the HA dash board works if i flip around binary sensor and switch. and home assistant can access the remote GPI and report the State fine but then randomy shuts off. and doesnt like you running cron…

sorry i missed something… ill send pics of the binsary sensor working

so here you see its working but its actually not working the Toggle Switch on HA is Off yet State says its ON also you see the 2 relays are ON yet its really off… it was never supposed to come on. or off… i did a reboot of the raspberry pi and HA set it

switch:
  - platform: remote_rpi_gpio
    host: 192.168.0.12
#    invert_logic: false
    ports:
        23: pump
        24: relay1
        25: relay2



 # Relay states
binary_sensor:
  - platform: remote_rpi_gpio
    host: 192.168.0.12
#    invert_logic: true
    ports:
        23: pump_state
        24: relay1_state 
        25: relay2_state
#    bouncetime: 50
#    pull_mode: "DOWN"

when HA reboots you see it resets RPI but it looses connection to sensors

now when i put sensors binary first it reads properly
but once again its flipping on 2 relays and keeping the other one off when all 3 should be turned off at intial state

 # Relay states
binary_sensor:
  - platform: remote_rpi_gpio
    host: 192.168.0.12
#    invert_logic: true
    ports:
        23: pump_state
        24: relay1_state 
        25: relay2_state
#    bouncetime: 50
#    pull_mode: "DOWN"

switch:
  - platform: remote_rpi_gpio
    host: 192.168.0.12
#    invert_logic: false
    ports:
        23: pump
        24: relay1
        25: relay2

i rebooted the rasbperry Pi. this is how it should look. i also made sure both invert logic are remmed out

i reboot HA and it shouldnt touch anything it should read the RPI and the buttons dont match they say they Off yet the State is ON

see you can see it works but doesnt work… also my Pump Relay webserver switch works but HA bricks it so it doesnt work…
now it if hit STOP
Raspberry Pi webserver still stuck… but if i run my python code
pump.py 22 off then it will fix GPIO 25 as i use actual pin for the pump.py not the BCM

so then i restart HA after i made sure all 3 Relays are set to OFF
but Server cant be restarted after you STOP under configuration you gotta Reboot the whole thing
and then the switchs dont work but the sensors do and once again it flips on 2 lower relays but is keeping the first one off (pump) but if i did the invert logic of course the 2 lower stay Off and Pump goes on at HA restart

thats why i say i can get it to work but then it goes haywire it chooses to do whatever on its own…
im sure its configure wrong

so like i was saying it can read it at times… but it will go haywire malfunction doesnt read states right… but you were saying its just hasnt been looked at enough due to its volunter work… so it was just addon i wanted to try to incorporate it… and still has bugs i realise now in the rpi remote gpi… so maybe later this year it get tweaked out
and im sure your going to say… i did this all wrong i should have gone a different route in HA to get it to work right
but least you got pics to help me explain

i ended up ordering a wifi plug i couldnt get the ones you mention on amazon either was saying wont come till Late Jan Late Feb… so i tried another one so ill see how it goes whenever it comes…

OK, you are getting close now. In your configuration.yaml, you are using the same ports 23, 24 and 25 for the switches and the sensors. Each port can only be used once’ and that is by the HA and the python program you are running. Thats what it means when it says HA expects to be the sole user of the GPIO pin. So either the field device pulls the GPIO low for the sensor, or the RPi cpu pulls the port low for a switch, and yes you can invert that. Just be sure to think through the pull up and pull downs if you use them. Thats why it switches back and forth, its being asked to do two different things. Why not try to comment out one of the sections, ie. all the sensors or all the switches, depending on what the pins are wired to and see what it looks like, that will get one part going. Then you will have to use different ports for the other. Let me know how it goes.

ok so i remmmed out switch
i told my python script to reset the gpios
i restarted HA and it flips the 2 off keeps one on… and bricks the toggles on the RPI Web i have to ssh and command line my pump.py to turn it off

now i i change it remmed out the sensor and restarted… and no change of the switchs… and switchs toggle ok on HA to control the RPI relays

if i now rem out switch… and add the binars Sensor and add the invert i get

then i change the logic invert again

so its still flipping on 2 relays… and its bricking the RPI that using the Webserver doesnt work … clicking the buttons
i have to run my Pump.py 18 and 22 to off to get it reset and working on the RPI Webserver…
the webserver also uses BCM

oh and the reason i had set the Switchs and sensors to both the same numbers… i was trying different codes online… and since i dont have a real switch added just relays… they showed u use both the same numbers but i cant remember the link i tried sooo many different codes… but ya they uses Switch and binary switch the same port numbers… now i cant remember if there is a template thing as i havent figured how to do that…
and then i had tried to follow how to use Node-Red and i got confused…

but it seems that from what i see. no issues with switch: but the binary sensor is causing the RPi to flip on relays… even if the logic is false or true
its almost like the sensor is triggering it instead of reading but its weird how its doing it why 2 are affected other 1 not etc i been dealing with this scenario 2 weeks

So, as I mentioned above , you can’t have anything else controlling the same pins, so your web server, and your .py program, and your HA will all try to set GPIO pin configurations on the RPi, as they each wan’t to control it, and they are likely different in terms of pull-up, down or inverted, and it won’t likely work well, if at all. I would disable the webserver , stop the .py program however you are running that. Set up the 3 switches to run the relays and you only need to run this from HA. Restart the Pi, then restart HA after the pi is booted up. Then you should be able to toggle all 3 on and off independently. If they still don’t work disconnect the relay wires from the PI and see if the switches work properly.

well i dont have switchs on the pi so far i have 1 physical relay (pump) the 2 relay states are the 2 i was adding i just didnt wire up yet.

my pump.py is

#!/usr/bin/python

import RPi.GPIO as GPIO
import sys
GPIO.setwarnings(False)
pin = int(sys.argv[1])
status = sys.argv[2]
GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin,GPIO.OUT)
#GPIO.output(pin,GPIO.HIGH)
print status
if status == "on":
        GPIO.output(pin,GPIO.HIGH)
elif status == "off":
        GPIO.output(pin,GPIO.LOW)
#GPIO.cleanup()

so pin 16 = BCM 23
… pin 18 = BCM 24
…pin 22 = BCM 25

my pis config.txt
what this does is it forces the GPIO 23(16) to be in the off position if i dont relays start flickering or turn on turn off when first ititial booting u

gpio=23,24,25=op,dl

ok and i remmed out the rc.local for loading up the webserver

the way i run the schedule is on crontab

#Run Pump Every 2 Hours
# */2 * * * /home/pi/bin/pump.py 16 on
#Turn Pump Off Every 2 Hours 30 Min
#15 */2 * * * /home/pi/bin/pump.py 16 off

and thats what i want … u have to be able to turn on a switch externally directly to the pi in future… but ok
so disabled website boot up… disabled the crontabs rebooted the PI
Relay is off… i restarted Home Assistant and i get
plus i dont know how to add switchs now since i dont have toggles but either way its reporting

but i confused if you have a garage door… HA needs to know if you flip a switch to open or close… and then HA needs to read the state of the Relay pin… so really my pump.py is the same as flipping that switch… or would i need to flip 2 GPIOs one would be the relay the other is to simulate switch

either way it didnt matter i reboot both HA and Raspberry Pi

soo Intert Logic =False

invert logic = True

invert logic remmed out


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

      
# Example configuration.yaml entry
#sensor:
#  - platform: modem_callerid
#    device: /dev/ttyACM0

 # Relay states
binary_sensor:
  - platform: remote_rpi_gpio
    host: 192.168.0.12
#    invert_logic: false
    ports:
        23: pump_state
        24: relay1_state 
        25: relay2_state

i dont know how it can read pin 23 is ON yet its OFF and 24 25 are both set to OP,dl
so really when both boot up 23 24 25 should say OFF to HA yet its saying ON
fir the first one… i dont even know where its getting that info i got nothing else in that configuration.yami is there something else i need to look on rpi

i have no physical pins. for switchs… and only have Pin 23 (16) used at the moment and the other 2 are what i was adding for more features…

anywhere else ? or should i try a new clean install of HA and try and see what happens?

This is extremely dangerous advice. These wall plugs are advertised to turn on lamps and lights and general home items. They are current rated for a resistive load. The pump motor is a an inductive load, and is much harder to open the electrical circuit, with the rotating motor slowing down and being a generator. Typically a 10 amp resistive rated relay will only be rated approximately 3 or 3.5 amps inductive load. The motor has a high inrush current, and on opening the relay contacts can weld them selves closed, or result in arcing overheating and burning. House fires have occurred. See section 7 of this data sheet for a relay typically found in these devices: http://j5d2v7d7.stackpathcdn.com/wp-content/uploads/2015/10/SRD-05VDC-SL-C-Datasheet.pdf. People should really understand these things before they recommend them for purposes other than as advertised. Call an electrician, and use a proper motor contactor, the little relays can run the contactor. Peace

1 Like

ah
ya i dont use 10amp ones i use 30amp one
and my pump raspberry pi uses

so my 1 project uses (as its rated for 1HP motor and i use a 3/4 hp motor)

Remove the wiring from the relay and see if the switch operates like the other two. You cannot use the crontab to trigger the .py program which which is going to mess up HA. Once you get the switches and relays running you can use an automation in HA to run the pump. If the switch operates OK without the relay, please sketch how the relay is wired. Normally with a GPIO I use +3.3 to the VCC and then connect the relay pin to the GPIO, when the Pi pulls the gpio low, the relay turns on. This is not inverted. See how it goes.

thinking how Wifi light switchs work
it must do 2 things… 1… when you flip the switch turns light on… 2… sends a “hello world” to HA to say Light is ON

so if i kept my pumpy.py… id have to send a “Hello world” to HA to say Light is On so the toggle switch would flip on… and Hello World Off to HA to say Light is Off so the Toggle switch would flip off

and thhen if HA is not accessbile when you are using your light switchs… and when HA is running it then gets the State of the light switch and toggles the switchs in the proper mode… i just trying to figure i got everything disabled… and yet still reporting wrong… i shut off PI and i shut off HA and turned both on

and i still get Pump ON 2 other relays are OFF
i looked through all of HA i cant find anything that could be turning it on when it actuallity OFF the raspberry Pi…

maybe a new install i dunno

alright let me test ill get back to you