Firmata analog input, PWM/analog output, deprecate arduino (#40369)

* firmata analog input

* firmata pwm/analog out, use more HA const

* firmata update pymata to 1.19

* deprecate arduino, firmata supersedes it

* firmata sensor diff min, pull review quality changes

* firmata condense platform setup into loop
This commit is contained in:
Perry Naseck 2020-09-22 03:44:16 -04:00 committed by GitHub
parent 50b727ba83
commit 0582bf7746
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 379 additions and 57 deletions

View file

@ -4,16 +4,10 @@ import logging
from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME
from homeassistant.const import CONF_NAME, CONF_PIN
from homeassistant.core import HomeAssistant
from .const import (
CONF_INITIAL_STATE,
CONF_NEGATE_STATE,
CONF_PIN,
CONF_PIN_MODE,
DOMAIN,
)
from .const import CONF_INITIAL_STATE, CONF_NEGATE_STATE, CONF_PIN_MODE, DOMAIN
from .entity import FirmataPinEntity
from .pin import FirmataBinaryDigitalOutput, FirmataPinUsedException
@ -37,7 +31,7 @@ async def async_setup_entry(
api.setup()
except FirmataPinUsedException:
_LOGGER.error(
"Could not setup switch on pin %s since pin already in use.",
"Could not setup switch on pin %s since pin already in use",
switch[CONF_PIN],
)
continue
@ -55,7 +49,6 @@ class FirmataSwitch(FirmataPinEntity, SwitchEntity):
async def async_added_to_hass(self) -> None:
"""Set up a switch."""
await self._api.start_pin()
self.async_write_ha_state()
@property
def is_on(self) -> bool:
@ -64,12 +57,10 @@ class FirmataSwitch(FirmataPinEntity, SwitchEntity):
async def async_turn_on(self, **kwargs) -> None:
"""Turn on switch."""
_LOGGER.debug("Turning switch %s on", self._name)
await self._api.turn_on()
self.async_write_ha_state()
async def async_turn_off(self, **kwargs) -> None:
"""Turn off switch."""
_LOGGER.debug("Turning switch %s off", self._name)
await self._api.turn_off()
self.async_write_ha_state()