I have created a custom component to contorl my heating, and I would like to register services for switching on the boiler, changing thermostat setpoints, etc. My setup routines is:
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
heatingView = HeatingView(async_add_devices)
def handle_switch_on_boiler(call):
heatingView.switch_on_boiler()
hass.states.set('heatingcontrol.switch_on_boiler',None)
hass.services.async_register(DOMAIN, 'switch_on_boiler', handle_switch_on_boiler)
hass.http.register_view(heatingView )
return True
However, within the handle_switch_on_boiler function, the heatingView object won’t be available when the switch_on_boiler service is called. So, what is the correct way to expose the heatingView object within the handler?