def test_remove_state(self): """Test Python API set_state.""" hass.states.set('test.remove_state', 'set_test') self.assertIn('test.remove_state', hass.states.entity_ids()) remote.remove_state(master_api, 'test.remove_state') self.assertNotIn('test.remove_state', hass.states.entity_ids())
def test_remove_state(self): """Test Python API set_state.""" hass.states.set("test.remove_state", "set_test") self.assertIn("test.remove_state", hass.states.entity_ids()) remote.remove_state(master_api, "test.remove_state") self.assertNotIn("test.remove_state", hass.states.entity_ids())
def remove_state(self, entity_id): # ./set_state.py remove-state energy_asset.xxxxxx if remote.remove_state(api, entity_id): print(f'Successfully removed {entity_id}') else: print(f'Not successfully removed {entity_id}')
def cli(ctx, entity, action, new_state, attributes): """Get, set or remove the state of entity.""" import homeassistant.remote as remote if action == 'get': state = remote.get_state(ctx.api, entity) ctx.log('State of %s is %s', entity, state.state) if action == 'set': remote.set_state(ctx.api, entity, new_state, attributes=json.loads(attributes)) ctx.log('State of %s set to %s', entity, new_state) if action == 'remove': remote.remove_state(ctx.api, entity) ctx.log('Entitiy %s removed', entity) ctx.vlog('Entity: %s, Execute: %s', entity, timestamp())