Writing integration for P1

Hi, I have a P1->USB cable and an unemployed RPI2. HASS runs elsewhere in the network.

I know how to read out the P1 meter with python (there are a number of examples online), but I need some pointers on how to get the data stuffed into HASS.

Hello… I am using curl command to send back information to HA from a shell script…

Here is an example using a long lived token where 192.168.X.XXX is the local ip address of my HA instance. No need to have the entity created, this process is creating it. There are for sure many more solutions…

curl -d '{"state": "armed"}' http://192.168.X.XXX:8123/api/states/sensor.status_alarm_courcelles -H 'Authorization: Bearer   my_long_lived_token'

This is working as well from a python program… Here is an example (reading SMS on a USB stick and sending back info to HA):

def handleSms(sms):
    logging.info(u'== SMS message received ==\nFrom: {0}\nTime: {1}\nMessage:\n{2}\n'.format(sms.number, sms.time, sms.text))

    headers = {
        'Authorization': 'Bearer my_long_lived_token',
    }

    number = sms.number
    text = sms.text
    data = '{"state": "'+text+'"}'
    if number != '1984':
      response = requests.post('http://192.168.X.XXX:8123/api/states/input_text.received_sms_message_all', headers=headers, data=data)
      data = '{"state": "'+number+'"}'
      response = requests.post('http://192.168.X.XXX:8123/api/states/input_text.received_sms_message_phone', headers=headers, data=data)
      time = sms.time
      time = time.strftime("%Y-%m-%d %H:%M:%S")
      data = '{"state": "'+time+'"}'
      response = requests.post('http://192.168.X.XXX:8123/api/states/input_text.received_sms_message_time', headers=headers, data=data)
    else:
      response = requests.post('http://192.168.X.XXX:8123/api/states/input_text.received_sms_message_1984', headers=headers, data=data)
      time = sms.time
      time = time.strftime("%Y-%m-%d %H:%M:%S")
      data = '{"state": "'+time+'"}'
      response = requests.post('http://192.168.X.XXX:8123/api/states/input_text.received_sms_message_1984_time', headers=headers, data=data)

Where can I find what data to send for a P1 meter specifically?

What is a P1 meter ? Energy meter ?

Yes… How do get a sensor in HASS and how do know what fields I can post? That page doesn’t say.