I am not a programmer so bear with me, but like to learn:)
So far this is what I have and I would like to as a start to be able to make a device.sensor in indigo.
- Code: Select all
url = 'http://192.168.0.30:8123/api/states'
r = requests.get(url, headers={'Authorization': 'Bearer "TOKEN"', 'content-type': 'application/json'})
states = json.loads(r.content)
self.logger.info("Print content:\n%s" % (states))
This is returning something like this:
[{u'entity_id': u'sensor.bad_taklys_kwh',
u'last_updated': u'2019-01-08T13:52:12.761034+00:00',
u'last_changed': u'2019-01-08T13:52:12.761034+00:00',
u'state': u'307.64',
u'context': {u'user_id': None, u'id': u'88ff02b8a17f4676b9a9fee4895de41d'},
u'attributes': {u'unit_of_measurement': u'Kwh', u'friendly_name': u'Bad taklys Kwh'}},
..........
So for each device I have following attributes: entity_id, state, last_changed and attributes.
My first question is how can I make alle "entity_id" that is starting with "sensor." available to add it as a sensor device in indigo?