lundi 30 octobre 2017

how to avoid repeat the condition many times by if statement in python?

there is better way to avoid repeat the condition many times by if statement?

 for entity in entities:
        if (entity.entity_id.startswith('sensor') and  "sourcenodeid" not in entity.entity_id and "interval" not in entity.entity_id and "previous"  not in entity.entity_id and "exporting" not in entity.entity_id and "management" not in entity.entity_id and "yr" not in entity.entity_id and "alarm" not in entity.entity_id ):
            data = remote.get_state(api, entity.entity_id)
            #print(data)

i tried with or but it doesnt york properly because i got entity with condition yhich sould not be store it in data

Aucun commentaire:

Enregistrer un commentaire