I uploaded my latest config files to the instructable.
Without info from the developer console log in chrome, I can’t do anything. Do note that the 8888 url is only for testing. I now proxy UV4L on port 9090 using traefik which automatically gives me https. In my lovelace config, I thus use the https://myhost:9090 now (proxied via traefik).
A Pi zero W could not handle the load with me (or I don’t have enough patience)
I got u4vl running on buster as described above. As I said when I connect to https://myhost:9090 and click on WebRTC I get two way audio. Video is working, too.
But I have no idea why the DoorPi demo is not working (but you say thats not really important).
How can I get you that log? Maybe I should just go on with the Home Assistant integration from the instructable and see if that works tomorrow.
I have a problem with the input button. Maybe I’m doing it completely wrong…
I configured Pin 18 (GPIO24) as button 1. I exported the pin and set the direction to in. Then I started pi-mqtt-gpio and connected Pin 18 and 1 with a wire. My expectation was that I see the pin triggered in mqtt-gpio, but nothing happens.
Am I missing something?
edit: I used a little Python script to check if my button on Pin 18 is working and it is.
edit2: The button seems to be working, I get an incoming call. However no audio yet and when I click hangup, the log says:
edit3: No it was just the initial state of the button triggering the card in Home Assistant because I change the “on” and “off” payload in the config. Still no reaction to the button.
Yes I added everything. Will now double check each line. Is it expected that I see something on the console running the mqtt-gpio script when I press the button?
Of course I don’t expect you to answer immediately, I’m thankful for any help you can provide
Mmm, to be honest, I don’t know if you see something in the console when you press a button. I test it using MQTTBox, a chrome plugin where you can subscribe to MQTT topics (I subscribe to the topic doorbell/#). Then, we you press the doorbell, you should see something in the MQTTBox UI.
Perfect, will install that plugin at home, will help me a lot. Then I will know where I have to continue troubleshooting: At the mqtt-gpio area or in Home Assistant already.
Hmmm…when I use a simple Python script I took from a tutorial to detect the button being pressed it works.
But mqtt-gpio does nothing when I press the button. Nothing happens in MQTTBox or on the shell…only the initial settings are sent upon startup. So the MQTT connection itself should be allright.
I found out that it is very simple to write a small python program publishing a key press on mqtt. Will give it a try tomorrow as I am stuck with pi-mqtt-gpio.
I installed paho-mqtt and wrote (that means: stole together ) a little script that publishes my buttonpress to mqtt topic doorbell:
import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
import paho.mqtt.publish as publish
import paho.mqtt.client as mqtt
def button_callback(channel):
publish.single("doorbell/", payload=None, qos=0, retain=False, hostname="<mqtt host>", port=1883, client_id="", keepalive=60, will=None, auth={'username':"<mqttuser>",'password':"<password>"}, tls=None, protocol=mqtt.MQTTv311, t$
print("Button was pushed!")
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(10, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Set pin 10 to be an input pin and set initial value to be pulled low (off)
GPIO.add_event_detect(10,GPIO.RISING,callback=button_callback) # Setup event on pin 10 rising edge
message = input("Press enter to quit\n\n") # Run until someone presses enter
GPIO.cleanup() # Clean up
Home Assistant notices the button press and input_boolean.doorbel is turned on by the automation. On the doorpi card I get the option to accept and reject the call, and when I click Accept that changes to end call.
And where should I put the signalling.js and main.js? Also into /www/doorpi? And should I add them under resources: in the ui-lovelace.yaml? (edit: from checking the doorpi-card.js I assume they just have to reside in the same directory as doorpi-card.js)
And is it ok to remove the configuration for the server on port 8888?
So many questions, sorry
edit:
I FINALLY GOT IT WORKING!!!
So stupid! It was not working as I had no SSL active on my Home Assistant and therefore were not able to allow access to the audio devices. Would be helpful if Chrome or Firefox had told me about blocking the access Quickly created SSL certificates and now it is working.
Have to finetune my buttonpress script now
edit:
Instead of putting more work in my button press mqtt script, I used the one I found here, with slight adjustments:
My version:
(added possibility to enter mqtt credentials and changed journal handler to work with custom systemd installed through “pip3 install systemd”. Changed GPIO mode to BOARD.
#!/usr/bin/python3
import RPi.GPIO as GPIO
import logging
import paho.mqtt.publish as publish
from time import sleep
from systemd import journal
log = logging.getLogger('mqtt_alarm')
log.addHandler(journal.JournaldLogHandler())
log.setLevel(logging.INFO)
MQTT_HOST = "<mqtthost>"
MQTT_TOPIC_PREFIX = "doorbell/input/"
MQTT_USER = "<username>"
MQTT_PASS = "<password>"
MQTT_CLIENT_ID = ""
MQTT_PAYLOADS = {
0: "Off",
1: "On",
}
# Dictionary of GPIO PIN to mqtt topic
PIN_MAP = {
10: "button_1",
}
GPIO.setmode(GPIO.BOARD)
def state_change_hadler(channel):
state = GPIO.input(channel)
if state:
log.info("Rising edge detected on {}".format(channel))
else:
log.info("Falling edge detected on {}".format(channel))
publish_event(channel, state)
def publish_event(pin, state):
topic = MQTT_TOPIC_PREFIX + PIN_MAP[pin]
payload = MQTT_PAYLOADS[state]
publish.single(topic, payload, hostname=MQTT_HOST, auth={'username':MQTT_USER,'password':MQTT_PASS}, retain=True, qos=2)
log.info("Published event, topic={}, payload={}, hostname={}".format(topic, payload, MQTT_HOST))
for pin, name in PIN_MAP.items():
GPIO.setup(pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(pin, GPIO.BOTH, callback=state_change_hadler, bouncetime=100)
state = GPIO.input(pin)
log.info("Mapped pin {:0>2d} to {}".format(pin, name))
log.info("... state {}".format(state))
publish_event(pin, state)
try:
while True:
sleep(60)
except KeyboardInterrupt:
log.info("Stopping...")
finally:
GPIO.cleanup()
Now I have to put some power to the door for the Pi but I found an unused power cable there already that I might be able to put back to life
When you use Traefik to make that all available over the Internet, that means you are forwarding a Pi Port through the router , right?
Thats a thing a totally want to avoid - to much stress tracking security for device and software… because IF somebody breaks in that network, he might even be able to open my door (didn’t implement something for that yet and still have to walk there on my own, but that might change, too).
I think I will stay with VPN for that.
Would be great of course if there was a way to make it available through nabu casa somehow… maybe through the ingress feature? Maybe by creating an own small hass.io addon? Will do some research if that might be possible…
I see. Naaa…since my QNAP got infected with a Malware and regarding the extremely poor information politic for that issue from QNAP I will never again expose my NAS to the Internet