API and Home Assistant config?

Hi crew,

I was pretty excited to see API available for the general community as I have just started using Home assistant.

Has anyone managed to intergrate Pulse into Hass? Care to share an example of your config?

I managed to return a response in cli using my api and device id with -
url --request GET “https://api.pulsegrow.com/devices/{deviceId}/recent-data” --header “x-api-key: {apiKey}”

But so far have not been able to find the time to learn to integrate it into Hass as I have yet to configure anything into config.yaml.

Any help would be appreciated

Thanks

2 Likes

Hey @grudge

I don’t have much experience with home assistant, but i took a quick look at their docs and came across this: Fetching Data | Home Assistant Developer Docs

It appears to use this class: https://github.com/home-assistant/core/blob/5f827f4ca64067ca886e0e4dcb0d1498689e1ded/homeassistant/helpers/update_coordinator.py#L27

Seems like you can poll an API to get that data into home assistant. I’d probably have to work with it a bit more to get something more helpful, but could probably throw together a demo pretty quickly.

edit: did some more digging, here’s a decent example of how to do what you’re trying to do: https://michilehr.de/how-to-integrate-an-external-api-into-home-assistant-an-example-with-the-ambee-pollen-api and some discussion on it here: Home Assistant Ambee Pollen API · GitHub

Sounds like a pretty cool setup, let me know if you end up needing some more help or something.

What would you control with the relays?

Hi, I’m trying to use the pulse grow vpd value to turn the dehumidifier on/off through home assistant.
I use the following code but it fails. Any idea to make it works please?

Pulse Grow Sensor

     - platform: command_line
       name:
        pulse_grow_vpd:
        command:'curl -X GET https://api.pulsegrow.com/devices/XXXXX/recent-data -H "x-api-key: XXXX"''
        value_template: '{{ value_json."vpd" }}'
        scan_interval: 60

Configuration validation Error Msg

Invalid config for [sensor.command_line]: required key not provided @ data[‘command’]. Got None
value should be a string for dictionary value @ data[‘name’]. Got OrderedDict([(‘pulse_grow_vpd’, None), (‘command:‘curl -X GET https://api.pulsegrow.com/devices/XXXXX/recent-data -H "x-api-key’, ‘XXXXX"’’’), (‘value_template’, ‘{{ value_json.“vpd” }}’), (‘scan_interval’, 60)]). (See ?, line ?).

@Toma_Chan I managed to get a few hours to play with this and got the config working. Hopefully we can collaborate and get this going.

In my config.yaml I added a line

sensor: !include sensor.yaml

I then created a new file named sensor.yaml and added this -

  - platform: rest
    resource: https://api.pulsegrow.com/devices/insertdeviceid/recent-data --header x-api-key:insertapikey
    value_template: '{{ value_json["vpd"] }}'
    name: "Pulse Grow"
    scan_interval: 20

Obviously put in your device id and api in the appropriate spots. Also just copy and paste these lines and change for each sensor where the “vpd” is. Device/sensor list is found on api docs page.
If youre like me youre not going to want to display or control every sensor Pulse offers in Hass so just add the ones you want.

Thats as far as i got so far. Its a working config for me. If you manage to advance please share.

edited code typo

Thanks grudge, really appreciate your prompt response and advice. I have replaced the device id and API Key with mine, and HASS show the Pulse Grow entity status is unknown. * from your suggestion code, the header is “x-apikey” which is different with the API document, and i tried to use “x-api-key”. However both doesn’t work.

Thanks for that, I edited to reflect my config. The api docs also add the “” but works without on my end.

Are you able to get a call a response if you put this in terminal or command prompt?

curl --request GET https://api.pulsegrow.com/devices/insertdeviceid/recent-data --header x-api-key:insertapikey

1 Like

Yes, the system response with the pulse grow current environment information.

No worries, lets keep exlporing the way to make it works. Thanks.

just so it’s clear, the correct header is x-api-key

and here’s a sample CURL request

curl --request GET "https://api.pulsegrow.com/devices/ids" --header "x-api-key: ****************************"

some systems might use no quotes, some might use single quotes ', some might use double quotes "

I’m also working to integrate Pulse into HASS. Although I’m able to get curl responses with my api key and device id, the code for HASS is still giving “Unknown” status for sensors.

Would you post the entire YAML code you are using?

@puckett
in your config.yaml put this line in-

sensor: !include sensor.yaml

if you dont already have a sensor.yaml file, create one and then add-

- platform: rest
  resource: https://api.pulsegrow.com/devices/yourdeviceID/recent-data
  method: GET
  value_template: '{{ value_json["vpd"] }}'
  name: "Pulse Grow"
  scan_interval: 20
  headers: 
    x-api-key: yourAPIkey

Developer tools>check config>restart

Screenshot from 2022-09-21 15-59-06

That worked! I think my issue was somehow formatting related since I was using a sensor directory for my sensors.

1 Like

Hi, is the API service working? Since 12 hours ago I’m having a hard time getting data through the API, the server replies “{ Message = Unable to resolve service for type ‘PulseCore.CommonOptions.ElectricImpOptions’ while trying to activate ‘PulseCore.Business.Services.DeviceService’., StatusCode = 500 }%”.

1 Like

@Toma_Chan Hi there! Sorry for the belated reply.

Just incase - the public api has been working since Monday. We experienced some downtime during the weekend.

1 Like

Hi, here’s how to get all sensors data with just one API call.
Please also check the notes below.

rest:
  - resource: https://api.pulsegrow.com/devices/{{YOUR-DEVICE-ID}}/recent-data
    headers: 
        x-api-key: {{YOUR-API-KEY}}
    sensor:
      - unique_id: pulsepro_vpd
        name: "PulsePro VPD"
        icon: mdi:cloud-refresh
        unit_of_measurement: 'kPa'
        value_template: '{{ value_json["vpd"] | round(2) }}'
      - unique_id: pulsepro_temperature
        name: "PulsePro Temperature"
        device_class: temperature
        unit_of_measurement: '°C'
        value_template: '{{ value_json["temperatureC"] | round(2) }}'
      - unique_id: pulsepro_humidity
        name: "PulsePro Humidity"
        device_class: humidity
        unit_of_measurement: '%'
        value_template: '{{ value_json["humidityRh"] | round(2) }}'
      - unique_id: pulsepro_light
        name: "PulsePro Light"
        icon: mdi:wall-sconce-flat
        unit_of_measurement: '%'
        value_template: '{{ value_json["lightLux"] | round(2) }}'
      - unique_id: pulsepro_pressure
        name: "PulsePro Pressure"
        device_class: pressure
        unit_of_measurement: 'hPa'
        value_template: '{{ (value_json["airPressure"] / 100) | round(1) }}'
      - unique_id: pulsepro_co2
        name: "PulsePro CO2"
        device_class: carbon_dioxide
        unit_of_measurement: 'ppm'
        value_template: '{{ value_json["co2"] }}'
      - unique_id: pulsepro_dew_point
        name: "PulsePro Dew Point"
        icon: mdi:thermometer-water
        unit_of_measurement: '°C'
        value_template: '{{ value_json["dpC"] }}'
      - unique_id: pulsepro_signal_strength
        name: "PulsePro Signal Strength"
        device_class: signal_strength
        unit_of_measurement: 'dB'
        value_template: '{{ value_json["signalStrength"] }}'
    binary_sensor:
      - unique_id: pulsepro_pluggedin
        name: "PulsePro Plugged In"
        icon: mdi:power-plug
        value_template: '{{ value_json["pluggedIn"] }}'

Don’t forget to replace {{YOUR-DEVICE-ID}} and {{YOUR-API-KEY}} with actual values.

A few notes:

  1. i’m using celsius for temperature values, if you’re in the US you may want to switch from temperatureC (celsius) to temperatureF (fahrenheit) and from dpC (dew point) to dpF
  2. there are a few more values you can retrieve, please check the Device Recent Data API documentation for a complete list
  3. you can rename unique_id and name values as you wish, same for icon. I’ld recommend to leave the device_class as is. Check the Home Assistant RESTful Sensor and RESTful Binary Sensor docs for more info
  4. i’ve converted the airPressure value in hPa, because it’s common for other devices and weather integrations. Edit the formula if needed
  5. by default the Home Assistant RESTful integration pulls new data every 30 seconds. You can refresh more (or less) often by setting the scan_interval option. But be careful if you’re using a free tier API or you’ve multiple devices:

Hobbyist users can use up to 4800 datapoints daily, Enthusiasts and Professionals 24000 and 120000, respectively

20 seconds scan interval = 4320 API calls per day (ok with Hobbyist tier)
10 seconds scan interval (or 20 seconds scan interval for 2 devices) = 8640 calls per day (Enthusiasts needed)
…and so on. Just keep in mind that 1 day = 86400 seconds, and the API datapoints limits.

1 Like

I copied this exactly into my configuration.yaml

I added my api key and device ID but when I add a sensor card on my dashboard it doesn’t display any values it just says “Unkown” . I created a sensor.yaml file and added this to test if it worked

  • platform: rest
    resource: https://api.pulsegrow.com/devices/yourdeviceID/recent-data
    method: GET
    value_template: ‘{{ value_json[“vpd”] }}’
    name: “Pulse Grow”
    scan_interval: 20
    headers:
    x-api-key: yourAPIkey
    I am able to create a card and VPD is displayed fine. I’m new to all of this so I’m sure it’s something I am doing wrong I’m just at a loss right now. Thanks

Mmh can you try creating a rest.yaml file, copy-paste my code starting from the 2nd line (- resource:).
Then add this line to configuration.yaml:
rest: !include rest.yaml

1 Like

Ok, I did that and the same thing happens. The card doesn’t display any values just “Unkown”