Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspi GPIO binary_sensor produces unreliable responses ("Doorbell Scenario") #10498

Closed
bahmrockk opened this issue Nov 10, 2017 · 74 comments · Fixed by #48170
Closed

Raspi GPIO binary_sensor produces unreliable responses ("Doorbell Scenario") #10498

bahmrockk opened this issue Nov 10, 2017 · 74 comments · Fixed by #48170

Comments

@bahmrockk
Copy link

Make sure you are running the latest version of Home Assistant before reporting an issue.

Home Assistant release (hass --version):
0.57.2

Python release (python3 --version):
Python 3.5.3

Component/platform:
Binary Sensor GPIO on Raspberry Pi ( binary_sensor rpi_gpio)

Description of problem:
The sensor does not trigger with very short connections. This sadly is the default case for the "Doorbell" Scenario.
A self-made python script works as expected. Within hass, the first activation is always ignored. Afterwards, approximately 1/3 are not registered.
An automation is not needed to reproduce.

Expected:
Even a short hit on a button should trigger the binary sensor 100% of the time - hass.io should behave identically to manually implemented python scripts in that regard.

Problem-relevant configuration.yaml entries and steps to reproduce:

   - platform: rpi_gpio
     ports:
         18: hass_doorbell

Python that is working fine with the same hardware-setup can be found here:
https://github.com/bahmrockk/homeassistantConfig/blob/master/doorbell.py

  1. Connect a button to the GPIO (e.g. http://www.instructables.com/id/Raspberry-Pi-IoT-Doorbell/ )
  2. Press that button
  3. Observe that it does not register 100% within the hass.io frontend (sometimes even only on release)

Additional info:
I have tried a lot of different configurations, playing around with bouncetimes, inverted logic, etc etc. I'm now at a 80% confidence level that this is indeed a bug and not me being stupid :)

@ziotibia81
Copy link
Contributor

Hi! rpi_gpio should trigger an update event every time that the gpio input change state.

Try with a "long" debouce time (250ms) and press button for at least 1 second. If this work every time, you have to play around electrical connection and debouce time.

The default scan interval is 30 seconds. Try to change it to an high value (300s) to ensure that during your test the gpio update occours only during an edge.
See Entity documentation.

Let me know.... bye!

@bahmrockk
Copy link
Author

Hey,

Thank you for the awesome fast reply!
Checked it and there's no change in behavior (bouncetime 250, scan_interval 300).

An error in the electrical circuit would cause the linked python script to not work as well though so I can rule that part out at least :)
I played around with the pull modes as well, changing the python to mimic a pull_up instead of the physical resistor, but the result is the same - custom script works like a charm but Home Assistant ignores inputs regulary.

One interesting thing that stood out this test: The Home Assistant frontend shows the sensor hass_doorbell as "on" after boot - but as soon as the bell is triggered once, it switches to "off" and stays that way - even though the visual feedback (the circle next to it) on whether the button is pressed still works from time to time.

Thanks a lot!

@ziotibia81
Copy link
Contributor

The python script linked work in a different way than hass:
Hass wait for an endge on input after debounce, the script read the input every 200ms without debouncing and, if the input is false, does something. For this reason you have to be sure of electrical contacts.

Post your question in the forum and we continue to discute in that place. We have tu be sure that your report is really a bug.

@bahmrockk
Copy link
Author

ah okay! Perhaps that's the 20% I was missing - I'll check back on Sunday with a fresh breadboard instead of the already existing ones and write back.

As this seems to be only me I'm more convinced that it's an error outside of HASS.io!

@MiKuBB
Copy link

MiKuBB commented Dec 30, 2017

Hi, I have same problem. Using gpio.binary_sensor to track electricity high tarrif, over 230V relay. Succesfulnes of HA measurement is cca 50%.

In raspberry gpio python docs (https://sourceforge.net/p/raspberry-gpio-python/wiki/Inputs/) I read, that interrupt detection method should be RISING. but HA using both. Is there any possibility to change interrupt detection method?

thank you.

@ziotibia81
Copy link
Contributor

HA wait wait for a rising or falling interrupt, when it occour HA read the input. This logis is almost correct. Is more probably that the problem is related to Contact bounce. If you have an oscilloscope you can verify. You can also try an hardware debounce circuit (ex RC).

@MiKuBB
Copy link

MiKuBB commented Jan 4, 2018

Thank you for hint. pull up resistor helped me, but don't understand why rpi3 built in pull up resistors can't be used, or is there any possibility how to use it ?

@ziotibia81
Copy link
Contributor

Default HA setup for rpi gpio as input is with internal pull up and it can be change in configuration.

@dmcilvaney
Copy link

I'm seeing some possibly related behaviours in my project and got frustrated enough to start some digging.

I have two toggle buttons, confirmed to work using a multi-meter. Unlike most cases these buttons latch until pushed again. They are often getting stuck out of sync with HA. I copied components/binary_sensor/rpi_gpio.py into my custom_components folder and added some logging.

As expected given polling is disabled, the update() function is never being called. The edge detect callback seems to usually trigger reliably but three issues arise:

  1. If an edge is missed for any reason HA never updates the state properly. What I think may be happening for some users: If a button gets stuck in the 'on' state, but is actually physically off, there will be no state change when the next edge detect occurs since the change is from 'on' to 'on'.

  2. Probably more worrying, the edge detect callback is sometimes reporting the wrong reading from the input eg: currently high, button goes low, edge detect triggers, input still reads as high. Maybe something is messing up RPi.GPIO?

  3. More than once I've seen edge detects trigger Low->High->Low. Each time the change occurs HA schedules an update, but sometimes they take time to run. If the first update takes long enough the second edge detection will have triggered and changed the state back to Low. The two updates will then both report the switch is Low. (Maybe a FIFO queue is needed here to guarantee all detected edges are passed to HA in order?)

I'm relatively new to HA so I'm not sure what the best way to debug this further is, but I figured I would share what I've found so far.

@tomlut
Copy link

tomlut commented Feb 16, 2018

Yeah there is definitely an issue with the gpio binary sensor. It triggers perfectly but often misses the edge on return to the off state. No amount of messing with the debug time helps (I tried from the default 50ms up to 1000ms). Neither does using internal or external pull-ups.

@ziotibia81
Copy link
Contributor

At this point we need help from rpi-gpio maintainer.
HA set both edge detection on a gpio. When there are an edge it read the input and update the state. Between edge and read there are twoo callbacks and other code that take time.....

Rpi-gpio pass to callback only the input where edge occours but not the reason of interrupt.
This is enough for rising or falling detection, but not for both.

The best thing could be a patch to C code of rpi-gpio and report to callback the channel number and the channel value.

@tomlut
Copy link

tomlut commented Feb 16, 2018

That sounds like a good solution. I had a look at the code ( https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/binary_sensor/rpi_gpio.py ) it’s python not C but still beyond my ability to fix.

@ziotibia81
Copy link
Contributor

There is a open ticket in raspberry-gpio-python library. It might be useful to refer this thread in that ticket.

@matkor
Copy link
Contributor

matkor commented Feb 17, 2018

Hoping to hear if my fix (https://sourceforge.net/p/raspberry-gpio-python/tickets/157/) helps in yours use case scenario, like it worked for me.

@jkobie
Copy link

jkobie commented Mar 5, 2018

I was having a lot of issues with consistency with HA and gpio inputs. Finally hooked scope up to gpio. Lots of bouncing around :

https://i.imgur.com/iD3xGTb.png

Added a decoupling capacitor to the gpio pin. The decoupling capacitor cleaned up the switch input on the gpio pin.

https://i.imgur.com/yaVrKs3.png

@tomlut
Copy link

tomlut commented Mar 5, 2018

This is not a debounce issue. I too have a DSO and can check this. My input is a clean 0/1/0 transition lasting about 0.5 sec. The problem is that short pulses on the gpio port are triggered reliably but often do not register a return to the inactive state. So far the only solution I have found is hardware. I stretch the pulse length with a 555 time IC in monostable mode. 2 seconds works reliably.

@jkobie
Copy link

jkobie commented Mar 5, 2018

Adding a debounce capacitor on the switch resolved the issue that I was having with gpio not tracking properly for me. YMMV.

I'm new to HA, BUT, I highly doubt that HA running python scripts, on a raspberry pi, with no interrupt driven events, is a great place to to expect real time events. It sounds like you came up with a good workaround.

@tomlut
Copy link

tomlut commented Mar 5, 2018

HA does use edge driven interrupts on the gpio. Just not very well.

@jkobie
Copy link

jkobie commented Mar 6, 2018

HA uses a call back based on hass.bus.listen_once event. It is not a real time interrupt, as described here: https://www.socallinuxexpo.org/sites/default/files/presentations/Steven_Doran_SCALE_13x.pdf

@tomlut
Copy link

tomlut commented Mar 6, 2018

Is the callback not generated by an edge detect interrupt?:


        def read_gpio(port):
            """Read state from GPIO."""
            self._state = rpi_gpio.read_input(self._port)
            self.schedule_update_ha_state()

rpi_gpio.edge_detect(self._port, read_gpio, self._bouncetime)

https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/binary_sensor/rpi_gpio.py

Edit/ also it does not have to be real-time. FIFO would be fine. It just has to register both edges reliably. Currently it only does the first edge reliably.

@jkobie
Copy link

jkobie commented Mar 6, 2018

How I understand the code, the setup sets a listener via hass.bus.listen_once.
rpio_gpio.edge_detect calls the callback when hass.buss changes state (up or down).

The event is at the mercy of hass.buss. What happens if hass.buss is busy off performing some other tasks?

@tomlut
Copy link

tomlut commented Mar 6, 2018

I know what happens. It misses the falling edge. It should be buffered or something. I'm just not able to produce a solution because my coding skill is wanting.

@matkor
Copy link
Contributor

matkor commented Mar 6, 2018

It misses the falling edge

In my case edge detection works reliable.
What is not working is reading pin state inside edge detected handler. After pin change state, inside handler, wrong value as before change is read and set as state:
self._state = rpi_gpio.read_input(self._port)

@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@tomlut
Copy link

tomlut commented May 30, 2018

I'm not in a position to test this until I can update to 0.70.0 (waiting on some custom panel updates). I'm currently on 0.69.1 and there is still a problem with the GPIO. Please do not close.

@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@ve6rah
Copy link

ve6rah commented Sep 29, 2020

@rarroyo6 as had been previously mentioned, a debounce circuit is not a solution to this issue. Sometimes genuinely short inputs are required for one reason or other, and it is inexcusable that the correct final state is not recorded.

The bounce isn't the problem, the problem is that home assistant frequently misses the final resting state of an input that lasts less than a certain amount of time.

I gave up on this bug getting fixed a long time ago and moved all my inputs to esp chips communicating by mqtt. It's unfortunate that home assistant, for all the things it does so well, is absolutely horrible at the basics of connecting to home devices (see both this, and the state of zwave). It seems that those who design/maintain hass do not use any devices that connect to it by either of those methods.

@bmsec
Copy link

bmsec commented Oct 11, 2020

I do have to say that it is rather silly that this issue is still open and still ignored. I see that there at least 2 pool requests that would (at least partially) solve the problem, and it seems to me that the only reason why non was merged is lack of interest.

So, for those who need this function and are not able to hack the code (not programmers), here is a partial solution that is usable if the application is not extremely critical:

  • set bouncetime 1
  • use a simple RC filter to denounce mechanical contacts (buttons). If the input is generated by an electric circuit (no bouncing) than the RC is not necessary.

How dose it work:
The problem has more parts, but the one making most of the problem is the Raspberry GPIO de-bounce implementation. As pointed out previously in this issue, it is not an actual de-bounce, it is just a 'trigger cut off' in case of state change, that in this particular situation dose more bad than good. So setting the bouncetime to 1 ms reduces to minimum the effect of this filter. Practically only events that are less than 1ms are not reported, so we need the RC filter to make shore that there will be no pulses that are shorter than 1 ms.

@CaptTom9
Copy link

I think the debounce logic may indeed be (at least part of) the problem. My GPIO pins are connected to a relay (contactor) with an AC coil. There could be some bounce in the signal. It's all starting to (finally) make sense to me. Rather than register the final state, HA simply gives up after some number of rapid state changes, leaving an almost random result.

It still amazes me that a problem like this can remain for years in a project with so many active developers. I guess it speaks to the level of abstraction most developers are working at. Sometimes all these multiple layers of higher-level languages puts us too far from the underlying hardware.

@infosie3
Copy link

Yes, incredible that is not resolved

@ReaLogics
Copy link

ReaLogics commented Jan 25, 2021

Does anyone know why RPI GPIO7 as a binary sensor does not configure? HA logs say "Failed to add edge detection" causing "platform: rpi_gpio" to fail. If I comment out GPIO7 "7: Bedroom 2 Window", then the remaining GPIO pins work fine. I am on RPI 3 B+ with HAOS 2021.1.5. GPIO7 use to work a year or two ago.

FYI: I resolved the RPI GPIO edge trigger issue by creating a PI Shield PWBA incorporating ATmega328p to do S/W debounce of magnetic relay inputs from doors and windows. I settled on requiring relay inputs to ATmega328p to be stable for 25ms, before reporting HIGH->LOW or LOW->HIGH transitions to GPIO pins. 25ms is plenty fast enough for button and relay inputs, and plenty slow enough for the RPI to respond and not miss an edge. So incorporating S/W debouncing in HA python code is the answer.

binary_sensor:
  - platform: rpi_gpio
    invert_logic: true
    ports:
      4: Living Room PIR
      5: Living Room Window
      6: Bedroom 1 Window
      7: Bedroom 2 Window
      22: Bedroom 3 Window
      23: Bathroom Window
      24: Kitchen Window
      25: Front  Door
      26: Sliding Door
      27: Carport Door   

@nonkronk
Copy link

nonkronk commented Feb 4, 2021

Just posted a pull request which (hopefully) fixes the problem. No idea whether it'll be accepted or not,
so, if you don't want to wait, create the "config/custom_components/rpi_gpio2" directory in your HA installation, extract the attached zip into, change the domain of your gpio binary sensors from "rpi_gpio" to "rpi_gpio2" and restart. It works fine for me; let me know if it does for you.

rpi_gpio2.zip

You saved my day...I can't believe this issue still persist in 2021.

@cvdabbeele
Copy link

I just wanted to confirm that the rpi_gpio2.zip works for me as well.
When I moved to a RPI4 with harddisk with Rasbian and docker containers, I was no longer able to get any inputs to work from GPIO This rpi_gpio2 fixed it !

A big thank you to @greg2001 I have been chewing on this issue for weeks

Can you elaborate a bit on what you changed?
I'm trying to gauge the impact on my RPI4, but I can't make much sense of greg2001@cfc12d6 (not being a developer)
Are you re-reading all GPIOs at "_bouncetime/1000"?
Is that the bouncetime that we can configure in the yaml files of Home Assistant?
Great Job ! I can finally move on with my migration to the RPI4
ChrisV

@CaptTom9
Copy link

I just wanted to confirm that the rpi_gpio2.zip works for me as well.
When I moved to a RPI4 with harddisk with Rasbian and docker containers, I was no longer able to get any inputs to work from GPIO This rpi_gpio2 fixed it !

A big thank you to @greg2001 I have been chewing on this issue for weeks

Thank you for running the test to confirm this works, and I'll add my thanks to @greg2001, too!

Now, how do we get this thing accepted? A year seems a long time to wait.

mburget added a commit to mburget/core that referenced this issue Mar 20, 2021
…unreliable responses ("Doorbell Scenario")

Changes overtaken from PR#31788 which was somehow never finished
mburget added a commit to mburget/core that referenced this issue Mar 20, 2021
…unreliable response. Changes taken over from PR31788 which was somehow never finished
@mburget
Copy link
Contributor

mburget commented Mar 21, 2021

Hi all
I give it a try: I created a PR to have the rpi_gpio2 solution (without threads) to be merged. See above.

@ReaLogics
Copy link

I will give it a test this week.

@ReaLogics
Copy link

Tested on RPI 3 B+ with HAOS 2021.3.6 with following configuration:

binary_sensor:

  • platform: rpi_gpio2
    invert_logic: true
    ports:
    4: Living Room PIR
    5: Living Room Window
    6: Bedroom 1 Window
    17: Bedroom 2 Window
    22: Bedroom 3 Window
    23: Bathroom Window
    24: Kitchen Window
    25: Front Door
    26: Sliding Door
    27: Carport Door

Works as desired. Pin states were accurately reported.

@ReaLogics
Copy link

I do see this in the log:

BinarySensorDevice is deprecated, modify RPiGPIOBinarySensor to extend BinarySensorEntity
March 23, 2021, 8:09:03 PM – Binary sensor (WARNING)

No 'version' key in the manifest file for custom integration 'rpi_gpio2'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'rpi_gpio2'
March 23, 2021, 8:09:03 PM – loader.py (WARNING)

@mburget
Copy link
Contributor

mburget commented Mar 24, 2021

Hi,
I think we have a missunderstanding.
The warning in the log means you tested the solution out of the older zip file and Not the provided pull request for the homeassistant main repo.

@mburget
Copy link
Contributor

mburget commented Mar 24, 2021

Technically pretty the same but without thread which Blocked the previous PR to be merged

@Misiu
Copy link
Contributor

Misiu commented Mar 24, 2021

@ReaLogics also the first error won't occur in the final solution, as BinarySensorEntity is already used as a base class - https://github.com/home-assistant/core/pull/48170/files#diff-b8f4dc78d24beb32fff650f40c8846f919c1654ab5e68cec459acd6bd61fa97aR55

I hope #48170 will be merged soon. The next beta will be released on 31 March, so not much time left.

@f-mosquera
Copy link

Hi, I have 10 binary sensors in a Raspberry Pi 4 running hassos. I finally had a working system thanks to the rio_gpio2 zip solution, but would really like to have a fix that is merged without the need of the workaround. I am pretty new to home assistant so the only way I found to try to test the pull request is to do something similar to the other workaround using a custom_component. So I created a folder named rio_gpio3. I'll post below the content of the files. I have been running it for around an hour and it seems to be detecting the states correctly, with one glitch. When I restart the server it sometimes raises the following error in the log:

Uncaught exception
8:22:57 – custom_components/rpi_gpio3/binary_sensor.py (ERROR)

The details are:

Logger: root
Source: custom_components/rpi_gpio3/binary_sensor.py:81
First occurred: 8:22:57 (1 occurrences)
Last logged: 8:22:57

Uncaught exception
Traceback (most recent call last):
File "/config/custom_components/rpi_gpio3/binary_sensor.py", line 81, in edge_detected
self.hass.add_job(self.async_read_gpio)
AttributeError: 'NoneType' object has no attribute 'add_job'

Hope this helps

@f-mosquera
Copy link

f-mosquera commented Mar 27, 2021

/config/custom_components/rpi_gpio3/__init__.py

"""Support for controlling GPIO pins of a Raspberry Pi."""
import logging

from RPi import GPIO  # pylint: disable=import-error

from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP

_LOGGER = logging.getLogger(__name__)

DOMAIN = "rpi_gpio3"
PLATFORMS = ["binary_sensor"]


def setup(hass, config):
    """Set up the Raspberry PI GPIO component."""

    def cleanup_gpio(event):
        """Stuff to do before stopping."""
        GPIO.cleanup()

    def prepare_gpio(event):
        """Stuff to do when Home Assistant starts."""
        hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup_gpio)

    hass.bus.listen_once(EVENT_HOMEASSISTANT_START, prepare_gpio)
    GPIO.setmode(GPIO.BCM)
    return True


def setup_output(port):
    """Set up a GPIO as output."""
    GPIO.setup(port, GPIO.OUT)


def setup_input(port, pull_mode):
    """Set up a GPIO as input."""
    GPIO.setup(port, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP)


def write_output(port, value):
    """Write a value to a GPIO."""
    GPIO.output(port, value)


def read_input(port):
    """Read a value from a GPIO."""
    return GPIO.input(port)


def edge_detect(port, event_callback, bounce):
    """Add detection for RISING and FALLING events."""
    GPIO.add_event_detect(port, GPIO.BOTH, callback=event_callback, bouncetime=bounce)

@f-mosquera
Copy link

f-mosquera commented Mar 27, 2021

/config/custom_components/rpi_gpio3/binary_sensor.py

"""Support for binary sensor using RPi GPIO."""

import asyncio

import voluptuous as vol

from .. import rpi_gpio3
from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity
from homeassistant.const import DEVICE_DEFAULT_NAME
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.reload import setup_reload_service

from . import DOMAIN, PLATFORMS


CONF_BOUNCETIME = "bouncetime"
CONF_INVERT_LOGIC = "invert_logic"
CONF_PORTS = "ports"
CONF_PULL_MODE = "pull_mode"

DEFAULT_BOUNCETIME = 50
DEFAULT_INVERT_LOGIC = False
DEFAULT_PULL_MODE = "UP"

_SENSORS_SCHEMA = vol.Schema({cv.positive_int: cv.string})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_PORTS): _SENSORS_SCHEMA,
        vol.Optional(CONF_BOUNCETIME, default=DEFAULT_BOUNCETIME): cv.positive_int,
        vol.Optional(CONF_INVERT_LOGIC, default=DEFAULT_INVERT_LOGIC): cv.boolean,
        vol.Optional(CONF_PULL_MODE, default=DEFAULT_PULL_MODE): cv.string,
    }
)


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Raspberry PI GPIO devices."""
    setup_reload_service(hass, DOMAIN, PLATFORMS)

    pull_mode = config.get(CONF_PULL_MODE)
    bouncetime = config.get(CONF_BOUNCETIME)
    invert_logic = config.get(CONF_INVERT_LOGIC)

    binary_sensors = []
    ports = config.get("ports")
    for port_num, port_name in ports.items():
        binary_sensors.append(
            RPiGPIOBinarySensor(
                port_name, port_num, pull_mode, bouncetime, invert_logic
            )
        )
    add_entities(binary_sensors, True)


class RPiGPIOBinarySensor(BinarySensorEntity):
    """Represent a binary sensor that uses Raspberry Pi GPIO."""

    async def async_read_gpio(self):
        """Read state from GPIO."""
        await asyncio.sleep(float(self._bouncetime) / 1000)
        self._state = await self.hass.async_add_executor_job(
            rpi_gpio3.read_input, self._port
        )
        self.async_write_ha_state()

    def __init__(self, name, port, pull_mode, bouncetime, invert_logic):
        """Initialize the RPi binary sensor."""
        self._name = name or DEVICE_DEFAULT_NAME
        self._port = port
        self._pull_mode = pull_mode
        self._bouncetime = bouncetime
        self._invert_logic = invert_logic
        self._state = None

        rpi_gpio3.setup_input(self._port, self._pull_mode)

        def edge_detected(port):
            """Edge detection handler."""
            self.hass.add_job(self.async_read_gpio)

        rpi_gpio3.edge_detect(self._port, edge_detected, self._bouncetime)

    @property
    def should_poll(self):
        """No polling needed."""
        return False

    @property
    def name(self):
        """Return the name of the sensor."""
        return self._name

    @property
    def is_on(self):
        """Return the state of the entity."""
        return self._state != self._invert_logic

    def update(self):
        """Update the GPIO state."""
        self._state = rpi_gpio3.read_input(self._port)

@f-mosquera
Copy link

f-mosquera commented Mar 27, 2021

/config/custom_components/rpi_gpio3/services.yaml

reload:
  description: Reload all rpi_gpio entities.

@mburget
Copy link
Contributor

mburget commented Mar 27, 2021

hi f-mosquera,
thanks for testing. The error you got seems to be related to timing on startup: the hass object seems not to be initialized. I think it is related to the use as a custom component.
If you want to test it as it will be if integrated you have to find the homeassistant/components/rpi_gpio/binary_sensor.py file on your system and replace it (temporaly) by the one out of the PR. The path were out can find it depends on your instalation and used python version.
to find the file a command like: find / -name "binary_sensor.py" | grep "/rpi_gpio/" can help

@dchanceafs
Copy link

Raspberry Pi 4 running hassos. The rio_gpio2 zip solution fixed my problem!

That needs to be moved into the production code!

@f-mosquera
Copy link

hi f-mosquera,
thanks for testing. The error you got seems to be related to timing on startup: the hass object seems not to be initialized. I think it is related to the use as a custom component.
If you want to test it as it will be if integrated you have to find the homeassistant/components/rpi_gpio/binary_sensor.py file on your system and replace it (temporaly) by the one out of the PR. The path were out can find it depends on your instalation and used python version.
to find the file a command like: find / -name "binary_sensor.py" | grep "/rpi_gpio/" can help

Thanks mburget, I tried your suggestion but as I'm running hassos those files don't show up. If there is an easy way to change that file in hassos or load a full version that contains it I can give it a try. Or if somebody has direct access to the components please test. I have been running for days the rpi_gpio3 setup as explained above, with the code that has been proposed for merge (without threading), and besides the glitch with the custom component at startup I can confirm that sensor states are detected correctly, as with the rpi_gpio2 solution.

@mburget
Copy link
Contributor

mburget commented Apr 2, 2021

hi f-mosquera,
yes my proposed testing is not possible on hassos. I'm testing it in a python virtual environment where this files are accessible. Thanks for your effort

MartinHjelmare pushed a commit that referenced this issue Apr 4, 2021
* Fix for issue #10498 Raspi GPIO binary_sensor produces unreliable responses ("Doorbell Scenario")

Changes overtaken from PR#31788 which was somehow never finished

* Fix for issue #10498 Raspi GPIO binary_sensor produces unreliable response. Changes taken over from PR31788 which was somehow never finished

* Remove unused code (pylint warning)
balloob pushed a commit that referenced this issue Apr 6, 2021
* Fix for issue #10498 Raspi GPIO binary_sensor produces unreliable responses ("Doorbell Scenario")

Changes overtaken from PR#31788 which was somehow never finished

* Fix for issue #10498 Raspi GPIO binary_sensor produces unreliable response. Changes taken over from PR31788 which was somehow never finished

* Remove unused code (pylint warning)
RenierM26 added a commit to RenierM26/core that referenced this issue Apr 9, 2021
* Bump HAP-python to 3.4.1 for homekit (home-assistant#48444)

* Bump aiodiscover to 1.1.2 for dhcp (home-assistant#48445)

* Remove myself as codeowner of HomematicIP Cloud (home-assistant#48437)

* [ci skip] Translation update

* Bump frontend to 20210328.0

* Address review comments from trace refactoring PRs (home-assistant#48288)

* Speed up bond setup with gather (home-assistant#48454)

* Bump aiodiscover to 1.2.0 in for dhcp (home-assistant#48456)

- Additional optimizations

* Fix template fan default speed count (home-assistant#48389)

* Fix template fan default speed count

The default speed count was defaulting to 3 when percentage
was implemented instead of the documented value of 100

* Increase coverage

* remove unreachable code

* Fix broken trace tests (home-assistant#48458)

* Fix knx tests (home-assistant#48407)

* Log the reason a config entry failed to setup (home-assistant#48449)

If we pass a string to ConfigEntryNotReady or raise it from
another exception we now log the string passed or the
string generated by the original exception.

With home-assistant#47201 this makes it easy for developers to still show
the reason why setup failed without having to worry about log
spam from additional attempts by rasing ConfigEntryNotReady
from the original exception.

* Don't write 0 to next modbus register (home-assistant#48378)

* Include platform only integrations in the manifest list api (home-assistant#48269)

* Do not load ignored or disabled integrations at startup (home-assistant#48355)

config_entries.async_setup will skip ignored and disabled integrations
but bootstrap would still load them in memory even though they would
never be setup.

* Add support for Selectors in Script service fields (home-assistant#48469)

* Fix unmute bug in vlc_telnet (home-assistant#48441)

If volume was muted and media_player.volume_up is fired, VLC would still
show up as muted.

PR extracted from home-assistant#44776.

* Allow specifying template entities based on triggers (home-assistant#48169)

Co-authored-by: Martin Hjelmare <[email protected]>

* Cloud: Expose if google is registered in status + check on login (home-assistant#48260)

Co-authored-by: Paulus Schoutsen <[email protected]>

* Command template support for MQTT fan (home-assistant#48413)

* Command template support

* Fix typo in abbreviations

* Update homeassistant/components/mqtt/fan.py

Co-authored-by: Erik Montnemery <[email protected]>

* Fix initialize templates

Co-authored-by: Erik Montnemery <[email protected]>

* Add screenshot to manifest (home-assistant#48475)

* Bump zwave-js-server-python to 0.23.0 to support zwave-js 7 (home-assistant#48094)

* Bump zwave-js-server-python to 0.23.0 and update integration to support schema changes

* refactor notification evenets a bit

* fix tests and bug fixes

* additional changes due to new PR

* add command class and command name

* use new event names so we can retain event property names

* handle command status being returned from async_set_config_parameter

* bump dependency version

* adjust log message to be consistent

* disable pylint warning

* Update homeassistant/components/zwave_js/services.py

Co-authored-by: Martin Hjelmare <[email protected]>

* add test for awake node

* switch async_get_registry to async_get

Co-authored-by: Martin Hjelmare <[email protected]>

* Make integration setup optional (home-assistant#48381)

* Add 'for' to cover device triggers (home-assistant#48324)

* Merge condition and action traces (home-assistant#48461)

* Clean up icons & device classes for Toon (home-assistant#48471)

* Allow MQTT entities to be disabled by default (home-assistant#48284)

* Allow MQTT entities to be disabled by default

* Tweak

* Refactor fan device triggers to use ToggleEntity triggers (home-assistant#48321)

* Bump aiodiscover to 1.3.0 to improve performance (home-assistant#48482)

* Create async_config_entry_first_refresh to reduce coordinator boilerplate (home-assistant#48451)

* Clean up superfluous integration setup - part 1 (home-assistant#48476)

* Clean up superfluous integration setup - part 2 (home-assistant#48478)

* Clean up superfluous integration setup - part 3 (home-assistant#48484)

* Remove HomeAssistantType alias from entity components - Part 1 (home-assistant#48467)

* Remove HomeAssistantType alias from entity components - Part 2 (home-assistant#48468)

* Add asyncio locks to screenlogic api access points (home-assistant#48457)

* [ci skip] Translation update

* Bump aiodiscoer to 1.3.2 for dhcp (home-assistant#48489)

- Removes unused code in the library
- Cleanup a small slow memory leak

* Add analytics integration (home-assistant#48256)

Co-authored-by: Martin Hjelmare <[email protected]>

* Add image proxy to Kodi media browser (home-assistant#47315)

* Bump frontend to 20210329.0

* Add zwave_js.bulk_set_partial_config_parameters service (home-assistant#48306)

* Add zwave_js.bulk_set_partial_config_parameters service

* update to handle command status

* add test for awake node

* test using a device in service call

* Update pylint to 2.7.3 (home-assistant#48488)

* Update pylint to 2.7.3

* Add class-const-naming-style

* Remove unused-import message

* Additional cleanup

* Create new websession if more than one entry in Tesla (home-assistant#47886)

* Create new websession if more than one entry
closes home-assistant#47506

* Remove extraneous count

* Always create new session

* Update docs

* Make devolo home control more robust against connection losts (home-assistant#48328)

* Fixed auth issue for non-2FA iCloud accounts (home-assistant#48455)

* Add opentherm_gw option for setpoint override mode (home-assistant#48465)

* Adding option for setpoint override mode

Temporary setpoint override mode can now be set on or off. 'Constant' setpoint override mode will be used when Temporary is set to off

* Changes after review comment

Added default value for the setpoint override mode

* Bump yalexs to 1.1.10 for august (home-assistant#48494)

- Remove workaround for broken reconnect logic in pubnub

* Use MAX_VOLUME constant in vlc_telnet (home-assistant#48491)

We also don't need to call `int()` anymore due to underlying fixes in
the python-vlc-telnet library.

I believe this is the last item extracted from PR home-assistant#44776.

* Include platform only integrations in analytics (home-assistant#48493)

* Add zwave_js.set_value service (home-assistant#48487)

Co-authored-by: Martin Hjelmare <[email protected]>

* Add myself as codeowner to analytics (home-assistant#48498)

* Update pylint to 2.7.4 (home-assistant#48500)

* Add 'for' to alarm device triggers (home-assistant#48503)

* Simplify device trigger code (home-assistant#48507)

* Add support for capturing renewals to dhcp discovery (home-assistant#48242)

* Add 'for' to vacuum device triggers (home-assistant#48506)

* Add 'for' to vacuum device triggers

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <[email protected]>

* Update test_device_trigger.py

* Update test_device_trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Add 'for' to media_player device triggers (home-assistant#48505)

* Add 'for' to media_player device triggers

* Update tests/components/media_player/test_device_trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update test_device_trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Add 'for' to lock device triggers (home-assistant#48504)

* Add 'for' to lock device triggers

* Update tests/components/lock/test_device_trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update test_device_trigger.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Raise Spotify exception if no active device found (home-assistant#48486)

* Add discovery for Tube's Zigbee coordinators to ZHA (home-assistant#48420)

* add discovery for tube zigbee gateways

* update discovery

* add test

* another test

* develop translations

* review comments

* Fix local mypy workflow (home-assistant#48433)

* Fix local mypy workflow

* Run mypy directly

* Correct FAA Delays integration domain in manifest (home-assistant#48512)

* Fix duplicates and unexpected failures during roomba discovery (home-assistant#48492)

* KNX passive group addresses (home-assistant#48009)

* Enable strict typing for zeroconf (home-assistant#48450)

* Enable strict typing for zeroconf

* Fix lutron_caseta

* Fix pylint warning

* Fix tests

* Fix xiaomi_aqara test

* Add __init__.py in homeassistant.generated module

* Restore add_job with type: ignore

* Add regex-based filters to logger component (home-assistant#48439)

* Add regex-based filters to logger component

* Switch logger filter tests to use caplog for more coverage, add a scoping test

* Evaluate AirVisual interval on reboot (home-assistant#48392)

* Reevaluate interval on reboot (and periodically)

* AirVisual update interval periodically

* AirVisual : update periodically interval request

* AirVisual : update sever request interval periodically

* AirVisual : periodically update interval for server requests

* AirVisual : periodic update for server interval

* Airvisual : periodic update of server interval

* AirVisual : periodic update of server interval

* AirVisual : periodic update of interval request

* Periodic interval update of server request

* AirVisual : periodic update of interval request

* Reassess interval request on periodic event

* ReAssess interval between 2 requests during update

* ReAssess interval between 2 requests periodically

* Reassess interval of server requests periodically

* Reassess the interval between 2 server requests

* Reassess interval between 2 server requests

* Reassess server requests interval periodically

* Assess interval request after inserting instance

* Remove analytics from updater (home-assistant#48518)

* support feedback for ZHA device reconfiguration (home-assistant#48447)

* Fix init for first added shelly device (home-assistant#48411)

* Search for areas used in automations and scripts (home-assistant#48499)

Co-authored-by: Martin Hjelmare <[email protected]>
Co-authored-by: Bram Kragten <[email protected]>
Co-authored-by: Paulus Schoutsen <[email protected]>

* Add target version to log about missing version (home-assistant#48520)

Co-authored-by: Franck Nijhof <[email protected]>

* [ci skip] Translation update

* Bump Synology DSM to 1.0.2 (home-assistant#48528)

* Bump Météo-France to 1.0.2 (home-assistant#48527)

* Bump Freebox to 0.0.10 (home-assistant#48526)

* Bump async_upnp_client to 0.16.0 (home-assistant#48521)

* Shield async httpx call in generic (home-assistant#47852)

* Shield async httpx call

* Don't set last_url/last_image on cancellation

* Add test

* Fix Sonos Line-in favorites (home-assistant#48524)

* Add support for ZHADoorLock locks to deCONZ integration(home-assistant#48516)

* Deprecate SolarEdge YAML configuration (home-assistant#48533)

* Remove if/else from modbus test cases (home-assistant#48514)

* Add color_mode support to MQTT JSON light (home-assistant#47993)

* Add vicare fuelcell (home-assistant#47167)

* Bump pyhaversion from 3.4.2 to 21.3.0 (home-assistant#48537)

* Add missing neato error status (home-assistant#48508)

* Add Plex library count sensors (home-assistant#48339)

* Use consolidated constant for "description" (home-assistant#48490)

* Add id to automation triggers (home-assistant#48464)

* Prevent ping integration from delaying startup (home-assistant#43869)

* Ensure HA script and Python script services have a name (home-assistant#47204)

Co-authored-by: Franck Nijhof <[email protected]>

* Improve error handling for WS API trace/get (home-assistant#48502)

* Set Plex sensor availability properly (home-assistant#48546)

* Update xknx to version 0.17.5 (home-assistant#48522)

Co-authored-by: Franck Nijhof <[email protected]>

* Avoid divide by zero errors in tplink light integration (home-assistant#48235)

* Fix update of surveillance_station data in Synology DSM (home-assistant#47966)

* Remove Hass.io terms in strings.json (home-assistant#48541)

Co-authored-by: Franck Nijhof <[email protected]>

* Create homekit locks according to spec (home-assistant#48453)

Any accessories, regardless of transport, that enable physical access to the home, such as door locks, must not be bridged.

* Update frontend to 20210331.0 (home-assistant#48552)

* Improve Plex device handling (home-assistant#48369)

* Add operation sensor to Shelly Gas (home-assistant#48462)

* Use Mapping[str, Any] instead of dict in Entity (home-assistant#48421)

* Add Qingping Air Monitor Lite support support  (home-assistant#48181)

* Add cgllc.airm.cgdn1 support

* review remarks

* removed unnecessary lambdas

* Use SOURCE_REAUTH constant for starting reauth flows (home-assistant#48553)

* Improve automation trace tests (home-assistant#48542)

* Provide the improved service UX with deCONZ services (home-assistant#48382)

Co-authored-by: Franck Nijhof <[email protected]>

* Add config flow support to google_travel_time (home-assistant#43509)

* add config flow support to google_travel_time

* fix bugs and add strings

* fix import and add new test

* address comments in home-assistant#43419 since this is a similar PR

* fix default name and test

* add unique ID and device info

* fix test

* feedback from waze PR

* continue incorporating feedback from waze PR

* final fixes and update tests

* call update in lambda

* Update homeassistant/components/google_travel_time/sensor.py

Co-authored-by: Martin Hjelmare <[email protected]>

* additional fixes

* validate config entry data during config flow and config entry setup

* don't store entity

* patch dependency instead of HA code

* fixes

* improve tests by moving all patching to fixtures

* use self.hass instead of setting self._hass

* invert if

* remove unnecessary else

Co-authored-by: Martin Hjelmare <[email protected]>

* Bump version to 2021.5.0dev0 (home-assistant#48559)

* Remove analytics from default_config (home-assistant#48566)

* [ci skip] Translation update

* Fix incorrect constant import in Ambient PWS (home-assistant#48574)

* Remove device class timestamp from device condition and trigger (home-assistant#48431)

* Remove unit from garmin connect

* Remove unit from hvv departures

* Remove device class timestamp from device condition and trigger

* Remove unit from systemmonitor

* Use device class constant for timestamp in ring

* Cleanup orphan devices in onewire integration (home-assistant#48581)

* Cleanup orphan devices (home-assistant#47438)

* Refactor unit testing

* Filter device entries for this config entry

* Update logging

* Cleanup check

* Move cast config flow tests to test_config_flow (home-assistant#48362)

* Return config entry details for 1-step config flows (home-assistant#48585)

* Don't care about DPI entries when looking for clients to be restored from UniFi (home-assistant#48579)

* DPI switches shouldnt be restored, they're not part of clients to be restored

* Only care about Block and POE switch entries

* Fix timer.finish to cancel callback (home-assistant#48549)

Timer.finish doesn't cancel the callback, which can lead to incorrect early cancellation of the timer if it is subsequently restarted. 

Bug reported here: https://community.home-assistant.io/t/timer-component-timer-stops-before-time-is-up/96038

* Include script script_execution in script and automation traces (home-assistant#48576)

* Add nws sensor platform (home-assistant#45027)

* Resolve rebase conflict.

Remove logging

* lint: fix elif after return

* fix attribution

* add tests for None valuea

* Remove Entity import

Co-authored-by: Erik Montnemery <[email protected]>

* Import SensorEntity

Co-authored-by: Erik Montnemery <[email protected]>

* Inherit SensorEntity

Co-authored-by: Erik Montnemery <[email protected]>

* remove unused logging

* Use CoordinatorEntity

* Use type instead of name.

* add all entities

* add nice rounding to temperature and humidity

Co-authored-by: Erik Montnemery <[email protected]>

* Only raise integrationnotfound for dependencies (home-assistant#48241)

Co-authored-by: J. Nick Koston <[email protected]>
Co-authored-by: Paulus Schoutsen <[email protected]>

* Clean lazytox script (home-assistant#48583)

* Allow templatable service target to support scripts (home-assistant#48600)

* Upgrade numpy to 1.20.2 (home-assistant#48597)

* Include blueprint input in automation trace (home-assistant#48575)

* Typing improvements for SolarEdge (home-assistant#48596)

* Remove Geizhals integration (ADR-0004) (home-assistant#48594)

* Upgrade Astral to 2.2 (home-assistant#48573)

* Fix websocket search for related (home-assistant#48603)

Co-authored-by: Paulus Schoutsen <[email protected]>

* Add zwave_js WS API command to call node.refresh_info (home-assistant#48564)

* Add hive heat on demand (home-assistant#48591)

* Update frontend to 20210402.0 (home-assistant#48609)

* Clean up mobile app (home-assistant#48607)

Co-authored-by: Martin Hjelmare <[email protected]>

* Increase time out for http requests done in Axis integration (home-assistant#48610)

* [ci skip] Translation update

* Bump aioshelly to 0.6.2 (home-assistant#48620)

* Add variables to execute script (home-assistant#48613)

* Fix trigger template entities without a unique ID (home-assistant#48631)

* Going async with denonavr (home-assistant#47920)

Co-authored-by: J. Nick Koston <[email protected]>

* Remove duplicate test case in modbus switch (home-assistant#48636)

* Updated frontend to 20210402.1 (home-assistant#48639)

* Support modern config for the trigger based template entity (home-assistant#48635)

* [ci skip] Translation update

* Add modbus CONF_VERIFY_STATE to new switch config (home-assistant#48632)

Missed CONF_VERIFY_STATE in new switch config, when
copying from old switch config.

* Fix AEMET town timestamp format (home-assistant#48647)

Datetime should be converted to ISO format.

Signed-off-by: Álvaro Fernández Rojas <[email protected]>

* Bump aiodiscover to 1.3.3 for dhcp (home-assistant#48644)

fixes home-assistant#48615

* Make modbus WRITE_COIL use write_coils in case of an array (home-assistant#48633)

* WRITE_COIL uses write_coils in case of an array.

WRITE_REGISTER uses write_register/write_registers depending
on whether value is singular or an array.

WRITE_COIL is modified to be similar and uses
write_coil/write_coils depending on whether value is singular or an
array.

* Update SERVICE_WRITE_COIL to allow list.

* Add Compensation Integration (home-assistant#41675)

* Add Compensation Integration

Adds the Compensation Integration

* Add Requirements

add missing requirements to compensation integration

* Fix for tests

Fix files after tests

* Fix isort

ran isort

* Handle ADR-0007

Change the configuration to deal with ADR-0007

* fix flake8

Fix flake8

* Added Error Trapping

Catch errors.
Raise Rank Warnings but continue.
Fixed bad imports

* fix flake8 & pylint

* fix isort.... again

* fix tests & comments

fix tests and comments

* fix flake8

* remove discovery message

* Fixed Review changes

* Fixed review requests.
* Added test to test get more coverage.

* Roll back numpy requirement

Roll back numpy requirement to match other integrations.

* Fix flake8

* Fix requested changes

Removed some necessary comments.
Changed a test case to be more readable.

* Fix doc strings and continue

* Fixed a few test case doc strings
* Removed a continue/else

* Remove periods from logger

Removed periods from _LOGGER errors.

* Fixes

changed name to unqiue_id.
implemented suggested changes.

* Add name and fix unique_id

* removed conf name and auto construct it

* Add retry mechanism on onewire sysbus devices (home-assistant#48614)

* Add retry mechanism on sysbus

* Update tests

* Move to async

* Move blocking calls on the executor

* Prevent config entry retry from blocking startup (home-assistant#48660)

- If there are two integrations doing long retries async_block_till_done() will never be done

* [ci skip] Translation update

* Make sonos event asyncio (home-assistant#48618)

* Only listen for zeroconf when the esphome device cannot connect (home-assistant#48645)

* Optimize storage collection entity operations with asyncio.gather (home-assistant#48352)

* Fix Raspi GPIO binary_sensor produces unreliable responses (home-assistant#48170)

* Fix for issue home-assistant#10498 Raspi GPIO binary_sensor produces unreliable responses ("Doorbell Scenario")

Changes overtaken from PR#31788 which was somehow never finished

* Fix for issue home-assistant#10498 Raspi GPIO binary_sensor produces unreliable response. Changes taken over from PR31788 which was somehow never finished

* Remove unused code (pylint warning)

* Apply ConfigEntryNotReady improvements to PlatformNotReady (home-assistant#48665)

* Apply ConfigEntryNotReady improvements to PlatformNotReady

- Limit log spam home-assistant#47201
- Log exception reason home-assistant#48449
- Prevent startup blockage home-assistant#48660

* coverage

* Upgrade pytest to 6.2.3 (home-assistant#48672)

* Upgrade holidays to 0.11.1 (home-assistant#48673)

* Remove modbus duplicate strings (home-assistant#48654)

* Reuse HA constants for serial configuration.

Reusing HA consts reduces the need for translation.

Sort/group constants in const.

* Change const name ATTR_* to CONF_*

* Correct wrong import

* ATTR_* for service and CONF_* for schemas.

* Revert change to service call.

* Rename CONF_TEMPERATURE -> ATTR_TEMPERATURE

Avoid possible division problem in set_temperature.

* Remove Social Blade integration (ADR-0004) (home-assistant#48677)

* Remove Social Blade integration (ADR-0004)

* Cleanup coveragerc

* Add modbus write coils (home-assistant#48676)

* Add missing function in class.

write_coils was missing.

* Remove dead code.

The HA configuration secures that CONF_TYPE only contains legal values,
so having an empty assert to catch unknown values is dead code.

An empty assert is not informative.

* Bump zwave_js dependency to 0.23.1 (home-assistant#48682)

* Cleanup sonos (home-assistant#48684)

- Remove unused code
- Use async_add_executor_job
- Enforce typing

* Upgrade wakonlan to 2.0.0 (home-assistant#48683)

* Use shared aiohttp.ClientSession in bond (home-assistant#48669)

* [ci skip] Translation update

* Add more device triggers to deCONZ integration (home-assistant#48680)

* Limit log spam from rest and include reason in platform retry (home-assistant#48666)

- Each retry was logging the error again
- Now we set the cause of the PlatformNotReady to allow Home Assistant to log as needed

* Fix sonos volume always showing 0 (home-assistant#48685)

* Implement Ignore list for poll control configuration on Ikea devices (home-assistant#48667)

Co-authored-by: Hmmbob <[email protected]>

* Add config flow for enphase envoy (home-assistant#48517)

Co-authored-by: Paulus Schoutsen <[email protected]>

* Add emonitor integration (home-assistant#48310)

Co-authored-by: Paulus Schoutsen <[email protected]>

* Provide api to see which integrations are being loaded (home-assistant#48274)

Co-authored-by: Paulus Schoutsen <[email protected]>

* Update all systemmonitor sensors in one executor call (home-assistant#48689)

Co-authored-by: Paulus Schoutsen <[email protected]>

* Fix verisure deadlock (home-assistant#48691)

* Add ClimaCell v4 API support (home-assistant#47575)

* Add ClimaCell v4 API support

* fix tests

* use constants

* fix logic and update tests

* revert accidental changes and enable hourly and nowcast forecast entities in test

* use variable instead of accessing dictionary multiple times

* only grab necessary fields

* add _translate_condition method ot base class

* bump pyclimacell again to fix bug

* switch typehints back to new format

* more typehint fixes

* fix tests

* revert merge conflict change

* handle 'migration' in async_setup_entry so we don't have to bump config entry versions

* parametrize timestep test

* Clean and optimize systemmonitor (home-assistant#48699)

- Remove unneeded excinfo to _LOGGER.exception
- Use f-strings
- Switch last_boot to utc
- Cache psutil/os calls used by multiple attributes in the same update cycle

* Add a new weather integration - Met Éireann (home-assistant#39429)

* Added a new weather integration - Met Éireann

* Fix codespell error

* Update met_eireann to use CoordinatorEntity

* Remove deprecated platform setup

* Fix merge conflict

* Remove unnecessary onboarding/home tracking code

* Use common strings for config flow

* Remove unnecessary code

* Switch to using unique IDs in config flow

* Use constants where possible

* Fix failing tests

* Fix isort errors

* Remove unnecessary DataUpdateCoordinator class

* Add device info

* Explicitly define forecast data

* Disable hourly forecast entity by default

* Update config flow to reflect requested changes

* Cleanup code

* Update entity naming to match other similar components

* Convert forecast time to UTC

* Fix test coverage

* Update test coverage

* Remove elevation conversion

* Update translations for additional clarity

* Remove en-GB translation

* Add config flow for Waze Travel Time (home-assistant#43419)

* Add config flow for Waze Travel Time

* update translations

* setup entry is async

* fix update logic during setup

* support old config method in the interim

* fix requirements

* fix requirements

* add abort string

* changes based on @bdraco review

* fix tests

* add device identifier

* Update homeassistant/components/waze_travel_time/__init__.py

Co-authored-by: J. Nick Koston <[email protected]>

* fix tests

* Update homeassistant/components/waze_travel_time/sensor.py

Co-authored-by: Martin Hjelmare <[email protected]>

* log warning for deprecation message

* PR feedback

* fix tests and bugs

* re-add name to config schema to avoid breaking change

* handle if we get name from config in entry title

* fix name logic

* always set up options with defaults

* Update homeassistant/components/waze_travel_time/sensor.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update config_flow.py

* Update sensor.py

* handle options updates by getting options on every update

* patch library instead of sensor

* fixes and make sure first update writes the state

* validate config entry data during config flow and entry setup

* fix input parameters

* fix tests

* invert if statement

* remove unnecessary else

* exclude helpers from coverage

* remove async_setup because it's no longer needed

* fix patch statements

Co-authored-by: J. Nick Koston <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>

* [ci skip] Translation update

* Add AMD Ryzen processor temperatur capability to systemmonitor (home-assistant#48705)

* Small improvements for emonitor (home-assistant#48700)

- Check reason for config abort
- Abort if unique id is already configured on user flow
- remove unneeded pylint

* Bump pychromecast to 9.1.2 (home-assistant#48714)

* Flag brightness support for MQTT RGB lights (home-assistant#48718)

* Bump codecov/codecov-action from v1.3.1 to v1.3.2 (home-assistant#48716)

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.3.1 to v1.3.2.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md)
- [Commits](codecov/codecov-action@v1.3.1...9b0b9bb)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Abort discovery for unsupported doorbird accessories (home-assistant#48710)

* Fix sync api use in alarm control panel test (home-assistant#48725)

* Updated frontend to 20210406.0 (home-assistant#48734)

* Fix infinite recursion in LazyState (home-assistant#48719)

If LazyState cannot parse the attributes of its row as JSON, it prints
a message to the logger. Unfortunately, it passes `self` as a format
argument to that message, which causes its `__repr__` method to be
called, which then tries to retrieve `self.attributes` in order to
display them. This leads to an infinite recursion and a crash of the
entire core.

To fix, send the database row to be printed in the log message, rather
than the LazyState object that wraps around it.

* Allow reloading top-level template entities (home-assistant#48733)

* Improve warnings on undefined template errors (home-assistant#48713)

* Add doorsensor + coordinator to nuki (home-assistant#40933)

* implemented coordinator + doorsensor

* added async_unload_entry

* small fixes + reauth_flow

* update function

* black

* define _data inside __init__

* removed unused property

* await on update & coverage for binary_sensor

* keep reauth seperate from validate

* setting entities unavailable when connection goes down

* add unknown error when entity is not present

* override extra_state_attributes()

* removed unnecessary else

* moved to locks & openers variables

* removed doorsensorState attribute

* changed config entry reload to a task

* wait for reload

* Fix systemmonitor IP address look-up logic (home-assistant#48740)

* Bump pysonos to 0.0.42 to fix I/O in event loop (home-assistant#48743)

fixes home-assistant#48732

Changelog: amelchio/pysonos@v0.0.41...v0.0.42

* Rename hassio config entry title to Supervisor (home-assistant#48748)

* [ci skip] Translation update

* Generate a seperate UUID for the analytics integration (home-assistant#48742)

* Add custom integrations to analytics (home-assistant#48753)

* Use microsecond precision for datetime values on MariaDB/MySQL (home-assistant#48749)

Co-authored-by: Paulus Schoutsen <[email protected]>

* New integration for Kostal Plenticore solar inverters (home-assistant#43404)

* New integration for Kostal Plenticore solar inverters.

* Fix errors from github pipeline.

* Fixed test for py37.

* Add more test for test coverage check.

* Try to fix test coverage check.

* Fix import sort order.

* Try fix test code coverage .

* Mock api client for tests.

* Fix typo.

* Fix order of rebased code from dev.

* Add new data point for home power.

* Modifications to review.
Remove service for write access (for first pull request). Refactor
update coordinator to not use the entity API.

* Fixed mock imports.

* Ignore new python module on coverage.

* Changes after review.

* Fixed unit test because of config title.

* Fixes from review.

* Changes from review (unique id and mocking of tests)

* Use async update method. Change unique id. Remove _dict

* Remove _data field.

* Removed login flag from PlenticoreUpdateCoordinator.

* Removed Dynamic SoC sensor because it should be a binary sensor.

* Remove more sensors because they are binary sensors.

* Met.no - only update data if coordinates changed (home-assistant#48756)

* Solve cast delaying startup when discovered devices are slow to setup (home-assistant#48755)

* Solve cast delaying startup when devices are slow to setup

* Update homeassistant/components/cast/media_player.py

Co-authored-by: Erik Montnemery <[email protected]>

Co-authored-by: Erik Montnemery <[email protected]>

* Do not activate Met.no without setting a Home coordinates (home-assistant#48741)

* Upgrade pre-commit to 2.12.0 (home-assistant#48731)

* Fix whitespace error in cast (home-assistant#48763)

* Update frontend to 20210407.0 (home-assistant#48765)

* Set AsusWRT mac_address and ip_address properties (home-assistant#48764)

* Remove login details before logging SQL errors (home-assistant#48758)

* Clean up google travel time code (home-assistant#48708)

* Bump actions/upload-artifact from v2.2.2 to v2.2.3 (home-assistant#48761)

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from v2.2.2 to v2.2.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v2.2.2...ee69f02)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update __init__.py (home-assistant#48659)

This change solves that HMIP-RCV-1 is not found when used in a service call to invoke a virtual key (case-sensitivity problem).
- https://community.home-assistant.io/t/homematic-hmip-rcv-50-not-working-with-virtual-key-any-more/249000
- https://github.com/danielperna84/pyhomematic/issues/368

* Update frontend to 20210407.1 (home-assistant#48778)

* Reject nan, inf from generic_thermostat sensor (home-assistant#48771)

* Remove doorbird recorder test workaround (home-assistant#48781)

Apparently this is no longer needed

* [ci skip] Translation update

* Store Recollect Waste pickup dates in UTC (home-assistant#48690)

* Store Recollect Waste pickup dates in UTC

* Code review

* Code review

* Account for openweathermap 'dew_point' not always being present (home-assistant#48826)

* Add Xiaomi Miio zhimi.airpurifier.mc2 (home-assistant#48840)

* add zhimi.airpurifier.mc2

* fix issort

* Fix iCloud extra attributes (home-assistant#48815)

* Update xknx to version 0.18.0 (home-assistant#48799)

* Return TP-Link sensor & light attributes as `float` rather than `string` (home-assistant#48828)

* Check all endpoints for zwave_js.climate fan mode and operating state (home-assistant#48800)

* Check all endpoints for zwave_js.climate fan mode and operating state

* fix test

* Add missing super call in Verisure Camera entity (home-assistant#48812)

* Bump speedtest-cli to 2.1.3 (home-assistant#48861)

* Correct wrong x in frontend manifest (home-assistant#48865)

* Fix optional data payload in Prowl messaging service (home-assistant#48868)

* Fix possibly missing changed_by in Verisure Alarm (home-assistant#48867)

* Let recorder deal with event names longer than 32 chars (home-assistant#47748)

* Fix subscribe_bootstrap_integrations to send events (home-assistant#48754)

* Raise an exception when event_type exceeds the max length (home-assistant#48115)

* raise an exception when event_type exceeds the max length that the recorder supports

* add test

* use max length constant in recorder

* update config entry reloaded service name

* remove exception string function because it's not needed

* increase limit to 64 and revert event name change

* fix test

* assert exception args

* fix test

* add comment about migration

* Add hive boost off functionality (home-assistant#48701)

* Add boost off functionality

* Added backwards compatibility

* Update homeassistant/components/hive/services.yaml

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/hive/climate.py

Co-authored-by: Martin Hjelmare <[email protected]>

Co-authored-by: Martin Hjelmare <[email protected]>

* Add manufacturer matching support to zeroconf (home-assistant#48810)

We plan on matching with _airplay which means we need
to able to limit to specific manufacturers to avoid
generating flows for integrations with the wrong
manufacturer

* Fix mysensor cover closed state (home-assistant#48833)

* Validate supported_color_modes for MQTT JSON light (home-assistant#48836)

* Update frontend to 20210407.2 (home-assistant#48888)

* Fix motion_blinds gateway signal strength sensor (home-assistant#48866)

Co-authored-by: Martin Hjelmare <[email protected]>

* Replace redacted stream recorder credentials with '****' (home-assistant#48832)

* Test that we do not initialize bad configuration (home-assistant#48872)

* Test that we do not initialize bad configuration

* Simplify test as we are not calling a service

* Catch expected errors and log them in rituals perfume genie (home-assistant#48870)

* Add update error logging

* Move try available to else

* Remove TimeoutError

* [ci skip] Translation update

* Fix logic reversal in sonos update_media_radio (home-assistant#48900)

* Don't get code_context when calling inspect.stack (home-assistant#48849)

* Don't get code_context when calling inspect.stack

* Update homeassistant/helpers/config_validation.py

* Fix cpu temperature reporting for Armbian on Odroid (home-assistant#48903)

Some systems expose cpu temperatures differently in
psutil. Specifically, running armbian on the Odroid xu4 sbc gives the
following temerature output:

>>> pp.pprint(psutil.sensors_temperatures())
{   'cpu0-thermal':
    [   shwtemp(label='', current=54.0, high=115.0, critical=115.0)],
    'cpu1-thermal':
    [   shwtemp(label='', current=56.0, high=115.0, critical=115.0)],
    'cpu2-thermal':
    [   shwtemp(label='', current=58.0, high=115.0, critical=115.0)],
    'cpu3-thermal':
    [   shwtemp(label='', current=56.0, high=115.0, critical=115.0)],
}

Since the cpu number is embedded inside the name, the current code
can't find it.

To fix this, check both the name and the constructed label for matches
against CPU_SENSOR_PREFIXES, and add the appropriate label
cpu0-thermal in the prefix list.

While this is slightly less efficient that just generating the label
and checking it, it results in easier to understand code.

* Add fixtures for Axis rtsp client and adapt tests to use them (home-assistant#47901)

* Add a fixture for rtsp client and adapt tests to use it

* Better fixtures for RTSP events and signals

* Bump pykodi to 0.2.4 (home-assistant#48913)

* Allow template covers to have opening and closing states (home-assistant#47925)

* Update "issur_melacha_in_effect" via time tracking (home-assistant#42485)

* AEMET town timestamp should be UTC (home-assistant#48916)

AEMET OpenData doesn't clarify if the hourly data timestamp is UTC or not, but
after correctly formatting the town timestamp in ISO format, it is clear that
the timestamp is provided as UTC value.
Therefore, the only values not provided as UTC are the ones related to the
specific daily and hourly forecast values.

Signed-off-by: Álvaro Fernández Rojas <[email protected]>

* Update Ezviz Component (home-assistant#45722)

* Update Ezviz Component

* Update Ezviz for pylint test

* Update Ezviz component pylint tests

* Update Ezviz component tests

* Update Ezviz Component tests

* Update Ezviz component pylint error

* Fix ezviz component config flow tests

* Update ezviz component

* Update Ezviz component

* Add sensor platforms

* issue with requirements file

* Update binary_sensor to include switches

* Updates to Ezviz sensors

* Removed enum private method.

* Fix switch args

* Update homeassistant/components/ezviz/switch.py

Co-authored-by: Martin Hjelmare <[email protected]>

* config flow checks login info

* Config_flow now imports ezviz from camera platform

* Update test

* Updated config_flow with unique_id and remove period from logging

* Added two camera services and clarified service descryptions in services.yaml

* Fixed variable name mistake with new service

* Added french integration translation

* Config_flow add camera rtsp credentials as seperate entities, with user step and import step

* rerun hassfest after rebase

* Removed region from legacy config schema, removed logging in camera platform setup that could contain credentials, removed unused constant.

* Regenerate requirements

* Fix tests and add config_flow import config test

* Added addition test to config_flow to test successfull camera entity create.

* Add to tests method to end in create entry, config_flow cleanup, use entry instead of entry.data

* Removed all services, sorted platforms in init file.

* Changed RTSP logging to debug from warning. (Forgot to change this before commit)

* Cleanup typing, change platform order, bump pyezviz version

* Added types to entries, allow creation of main entry if deleted by validating existance of type

* Config_flow doesn't store serial under entry data, camera rtsp read from entry and not stored in hass, removed duplicate abort if unique id from config flow

* Fix test of config_flow

* Update tests/components/ezviz/test_config_flow.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update tests/components/ezviz/test_config_flow.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update tests/components/ezviz/test_config_flow.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Bumped pyezviz api version, added api pyezvizerror exception raised in api (on HTTPError), cleanup unused imports.

* rebase

* cleanup coordinator, bump pyezviz api version, move async_setup_entry to add entry options to camera entries. (order change)

* Added discovery step in config_flow if cameras detected without rtsp config entry

* Reload main integration after addition or completion of camera rtsp config entry

* Add tests for discovery config_flow, added a few other output asserts

* Camera platform call discover flow with hass.async_create_task. Fixes to config_flow for discovery step

* Fix config_flow discovery, add check to legacy yaml camera platform import, move camera private method to camera import step

* Remove not needed check from config_flow import step.

* Cleanup config_flow

* Added config_flow description for discovered camera

* Reordered description in config_flow confim step.

* Added serial to flow_step description for discovered camera, readded camera attributes for rtsp stream url (allows user to check RTSP cred), added local ip and firmware upgade available.

* Bumped pyezviz version and changed region code to region url. (Russia uses a completly different url). PyEzviz adds a Local IP sensor, removed camera entity attributes.

* Add RSTP describe auth check from API to config_flow

* url as vol.in options in Config_flow

* Config_flow changes to discovery step, added exceptions, fixed tests, added rtsp config validate module mock to test disovery confirm step

* Add test for config_flow step user_camera

* Added tests for abort flow

* Extend tests on custom url flow step

* Fix exceptions in config_flow, fix test for discovery import exception test

* Bump pyezviz api version

* Bump api version, added config_flow function to wake hybernating camera before testing credentials, removed "user camera" step from config flow not needed as cameras are discovered.

* Create pyezviz Api instance for config_flow wake hybernating camera, fixed tests and added fixture to mock method

* Added alarm_control_panel with support to arm/disarm all cameras, fixed camera is available attribute (returns 2 if unavailable, 1 if available)

* Skip ignored entities when setup up camera RTSP stream

* Remove alarm_control_panel, add additional config_flow tests

* Cleanup tests, add tests for discovery_step.

* Add test for config_flow rtsp test step1 exceptions

* Removed redundant except from second step in test RTSP method

* All tests to CREATE or ABORT, added step exception for general HTTP error so user can retry in case of trasient network condition

* Ammended tests with output checks for step_id, error, data, create entry method calls.

* bumped ezviz api now rases library exceptions. Config_flow, coordiantor and init raises library exceptions. Updated test sideeffect for library exceptions

* Bump api version, Create mock ezviz cloud account on discovery tests first to allow more complete testing of step.

* Add abort to rtsp verification method if cloud account was deleted and add tests

* Update tests/components/ezviz/__init__.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/const.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update tests/components/ezviz/__init__.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Undo config import change to password key for yaml, move hass.data.setdefault to async_setup_entry and remove async_setup

* Fixed tests by removing _patch_async_setup as this was removed from init.

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Update homeassistant/components/ezviz/camera.py

Co-authored-by: Martin Hjelmare <[email protected]>

* Changed L67 on camera config to complete suggestion for cleanup

Co-authored-by: Martin Hjelmare <[email protected]>

Co-authored-by: J. Nick Koston <[email protected]>
Co-authored-by: SukramJ <[email protected]>
Co-authored-by: HomeAssistant Azure <[email protected]>
Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: Erik Montnemery <[email protected]>
Co-authored-by: mptei <[email protected]>
Co-authored-by: Pim <[email protected]>
Co-authored-by: Franck Nijhof <[email protected]>
Co-authored-by: David McClosky <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>
Co-authored-by: Bram Kragten <[email protected]>
Co-authored-by: Jan Bouwhuis <[email protected]>
Co-authored-by: Raman Gupta <[email protected]>
Co-authored-by: Kevin Worrel <[email protected]>
Co-authored-by: Joakim Sørensen <[email protected]>
Co-authored-by: Tobias Sauerwein <[email protected]>
Co-authored-by: Marc Mueller <[email protected]>
Co-authored-by: Alan Tse <[email protected]>
Co-authored-by: Guido Schmitz <[email protected]>
Co-authored-by: Niccolo Zapponi <[email protected]>
Co-authored-by: Martidjen <[email protected]>
Co-authored-by: Philip Allgaier <[email protected]>
Co-authored-by: David F. Mulcahey <[email protected]>
Co-authored-by: Ruslan Sayfutdinov <[email protected]>
Co-authored-by: Matthias Alphart <[email protected]>
Co-authored-by: Jacob Shufro <[email protected]>
Co-authored-by: jugla <[email protected]>
Co-authored-by: Michael <[email protected]>
Co-authored-by: Quentame <[email protected]>
Co-authored-by: Steven Looman <[email protected]>
Co-authored-by: uvjustin <[email protected]>
Co-authored-by: Anders Melchiorsen <[email protected]>
Co-authored-by: Robert Svensson <[email protected]>
Co-authored-by: jan iversen <[email protected]>
Co-authored-by: Nicolas Braem <[email protected]>
Co-authored-by: Vincent Le Bourlot <[email protected]>
Co-authored-by: jjlawren <[email protected]>
Co-authored-by: Marvin Wichmann <[email protected]>
Co-authored-by: Franck Nijhof <[email protected]>
Co-authored-by: Mario Limonciello <[email protected]>
Co-authored-by: LJU <[email protected]>
Co-authored-by: Simone Chemelli <[email protected]>
Co-authored-by: arturdobo <[email protected]>
Co-authored-by: Aaron Bach <[email protected]>
Co-authored-by: epenet <[email protected]>
Co-authored-by: youknowjack0 <[email protected]>
Co-authored-by: MatthewFlamm <[email protected]>
Co-authored-by: Paulus Schoutsen <[email protected]>
Co-authored-by: FMKaiba <[email protected]>
Co-authored-by: Khole <[email protected]>
Co-authored-by: Shay Levy <[email protected]>
Co-authored-by: Oliver <[email protected]>
Co-authored-by: Álvaro Fernández Rojas <[email protected]>
Co-authored-by: Petro31 <[email protected]>
Co-authored-by: mburget <[email protected]>
Co-authored-by: Alexei Chetroi <[email protected]>
Co-authored-by: Hmmbob <[email protected]>
Co-authored-by: Dylan Gore <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Justin Paupore <[email protected]>
Co-authored-by: Pascal Reeb <[email protected]>
Co-authored-by: Stefan Agner <[email protected]>
Co-authored-by: stegm <[email protected]>
Co-authored-by: Daniel Hjelseth Høyer <[email protected]>
Co-authored-by: Maciej Bieniek <[email protected]>
Co-authored-by: Daniel Sack <[email protected]>
Co-authored-by: Hans Kröner <[email protected]>
Co-authored-by: starkillerOG <[email protected]>
Co-authored-by: Marvin Wichmann <[email protected]>
Co-authored-by: Johan Nenzén <[email protected]>
Co-authored-by: Laszlo Magyar <[email protected]>
Co-authored-by: Milan Meulemans <[email protected]>
Co-authored-by: Phil Hollenback <[email protected]>
Co-authored-by: Brandon Rothweiler <[email protected]>
Co-authored-by: amitfin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment