the only thing i can think of is to make a custom switch for that.
or use appdaemon to automate it.
i took the demo switch and made a custom switch like this:
"""
Demo platform that has two fake switches.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
"""
import logging
import voluptuous as vol
from homeassistant.components.switch import (
ENTITY_ID_FORMAT, SwitchDevice, PLATFORM_SCHEMA)
from homeassistant.const import (
ATTR_FRIENDLY_NAME, CONF_VALUE_TEMPLATE, STATE_OFF, STATE_ON,
ATTR_ENTITY_ID, MATCH_ALL, CONF_SWITCHES)
from homeassistant.helpers.entity import generate_entity_id
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
ON_CODE = 'on_code'
OFF_CODE = 'off_code'
SEND_SWITCH = 'send_switch'
SWITCH_SCHEMA = vol.Schema({
vol.Optional(ATTR_FRIENDLY_NAME): cv.string,
vol.Required(ON_CODE): cv.string,
vol.Required(OFF_CODE): cv.string,
vol.Required(SEND_SWITCH): cv.entity_ids
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_SWITCHES): vol.Schema({cv.slug: SWITCH_SCHEMA}),
})
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the demo switches."""
switches = []
for device, device_config in config[CONF_SWITCHES].items():
friendly_name = device_config.get(ATTR_FRIENDLY_NAME, device)
on_code = device_config.get(ON_CODE, device)
off_code = device_config.get(OFF_CODE,device)
send_switch = device_config.get(SEND_SWITCH,device)
switches.append(DemoSwitch(hass, device, friendly_name, False, None, False,send_switch,on_code,off_code))
add_devices(switches)
class DemoSwitch(SwitchDevice):
"""Representation of a demo switch."""
def __init__(self, hass, device_id, friendly_name, state, icon, assumed,send_switch,on_code,off_code):
"""Initialize the Demo switch."""
self.hass = hass
self.entity_id = generate_entity_id(ENTITY_ID_FORMAT, device_id, hass=hass)
self._name = friendly_name
self._state = state
self._icon = icon
self._assumed = assumed
self._sendswitch = send_switch
self._on_code = on_code
self._off_code = off_code
@property
def should_poll(self):
"""No polling needed for a demo switch."""
return False
@property
def name(self):
"""Return the name of the device if any."""
return self._name
@property
def icon(self):
"""Return the icon to use for device if any."""
return self._icon
@property
def sendswitch(self):
"""Return the icon to use for device if any."""
return self._sendswitch
@property
def on_code(self):
"""Return the icon to use for device if any."""
return self._on_code
@property
def off_code(self):
"""Return the icon to use for device if any."""
return self._off_code
@property
def assumed_state(self):
"""Return if the state is based on assumptions."""
return self._assumed
@property
def is_on(self):
"""Return true if switch is on."""
return self._state
def turn_on(self, **kwargs):
"""Turn the switch on."""
self._state = True
data = {"V_IR_SEND":self._on_code,ATTR_ENTITY_ID: self._sendswitch}
self.hass.services.call("switch", "mysensors_send_ir_code", data)
self.update_ha_state()
def turn_off(self, **kwargs):
"""Turn the device off."""
self._state = False
data = {"V_IR_SEND":self._off_code,ATTR_ENTITY_ID: self._sendswitch}
self.hass.services.call("switch", "mysensors_send_ir_code", data)
self.update_ha_state()
now my mysensors 433 mhz remote is reached and in the yaml i have:
- platform: demo
switches:
eraamhoek:
friendly_name: Raamhoek
send_switch: switch.afstandbediening_40_1
on_code: 5570581
off_code: 5570580
epchoek:
friendly_name: PC hoek
send_switch: switch.afstandbediening_40_1
on_code: 5586965
off_code: 5586964
ewandmeubel:
friendly_name: Wandmeubel
send_switch: switch.afstandbediening_40_1
on_code: 5574677
off_code: 5574676
that can be changed for every service. all that really needs to be changed is the def turn_on and turn_off.
at that place could be a sleep 1 second and send again.