1 """Support for Firmata switch output."""
12 from .const
import CONF_INITIAL_STATE, CONF_NEGATE_STATE, CONF_PIN_MODE, DOMAIN
13 from .entity
import FirmataPinEntity
14 from .pin
import FirmataBinaryDigitalOutput, FirmataPinUsedException
16 _LOGGER = logging.getLogger(__name__)
21 config_entry: ConfigEntry,
22 async_add_entities: AddEntitiesCallback,
24 """Set up the Firmata switches."""
27 board = hass.data[DOMAIN][config_entry.entry_id]
28 for switch
in board.switches:
29 pin = switch[CONF_PIN]
30 pin_mode = switch[CONF_PIN_MODE]
31 initial = switch[CONF_INITIAL_STATE]
32 negate = switch[CONF_NEGATE_STATE]
36 except FirmataPinUsedException:
38 "Could not setup switch on pin %s since pin already in use",
42 name = switch[CONF_NAME]
44 new_entities.append(switch_entity)
50 """Representation of a switch on a Firmata board."""
53 """Set up a switch."""
54 await self.
_api_api.start_pin()
57 def is_on(self) -> bool:
58 """Return true if switch is on."""
59 return self.
_api_api.is_on
67 """Turn off switch."""
None async_added_to_hass(self)
None async_write_ha_state(self)
None async_turn_off(self, **Any kwargs)
None turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None turn_on(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)