and i did it and it works!!
my app:
###########################################################################################
# Home Assistant App for switching Mysensors (mysensors.org) 433 Mhz switch #
# If you have klik-aan-klik_uit, ELRO, Blokker or Action 433 Mhz switches, #
# all you have to do is to install a general mysensors sketch on an arduino #
# with a cheap 433 mhz sender. you can connect an infinitiv amount of switches with #
# up to 99 arduino nodes. #
# #
# the sketch can be found here: #
# https://community.home-assistant.io/t/general-mysensors-433-mhz-switch/2588/3 #
# this is an example from an appdaemon.cfg app part: #
# #
# [RFSwitch1] #
# module = RFSwitch #
# class = RFSwitch #
# switch01 = switch.remote_2_4 #
# switch02 = switch.remote_2_5 #
# switch03 = switch.remote_2_6 #
# switch04 = switch.remote_2_7 #
# total_switches = 3 #
# switchcode1 = rfaa02P01 #
# switchcode2 = rfab02P02 #
# switchcode3 = rfac02P03 #
# #
# explanation: #
# switch 01 to 04 are the 4 switches that the mysensors node create. #
# you can use more nodes just add 05, 06, 07, ... #
# total_switches is the amount you have in use. in this case P01,P02 and P03 #
# switchcode is build up from 3 parts. #
# 1) rfaa, rfab, rfac, ... the start from the name of the input_boolean you made #
# 2) 01, 02, 03, ..., 99 the number from the arduinoswitch you want to send the code to. #
# 3) P01, A31, M16, ... code to send #
# ELROcode => (A/E) buttoncode, (01/31) dipswitchcode #
# KAKUcode => (A/P) groupcode(dipswitch), (01/16) buttoncode #
# Blokkercode => (A) to keep the code unified, (01/16) buttoncode #
# Actioncode => (A/D) buttoncode, (01/?) dipswitchcode #
# #
# Rene Tode ( [email protected] ) #
# ( with a lot off help from Andrew Cockburn (aimc) ) #
# 2016/08/16 Germany #
# #
###########################################################################################
import appapi
class RFSwitch(appapi.AppDaemon):
def initialize(self):
self.listen_state(self.switch, "input_boolean")
def switch(self, entity, attribute, old, new, kwargs):
for counter in range(1,int(self.args["total_switches"])+1):
boolean_name_start= self.args["switchcode" + str(counter)][0:4]
switch_type = self.args["switchcode" + str(counter)][4:6]
switch_code = self.args["switchcode" + str(counter)][6:]
switch=self.args["switch" + switch_type]
if entity[14:18] == boolean_name_start:
if new == "on":
self.call_service("switch/mysensors_send_ir_code", entity_id = switch, V_IR_SEND=switch_code + "t")
else:
self.call_service("switch/mysensors_send_ir_code", entity_id = switch, V_IR_SEND=switch_code + "f")
this made my configuration.yaml already over 300 lines shorter.