Support for Local Neurio Power Sensor

So far it looks like the data is fed in, but it’s not accurate. It’s not intuitive as to why, either. I’m hoping this gets some revision in the next update to make it a bit more user friendly.

Hi, did the formatting change with a home assistant update or something? I can’t get the sensors to pull the data, specifically, anything after the channels object ( “…channels.3.p_W”)

When I input the data in the template area of HA’s developer section, it will list all the raw data if I use states.sensor.neurio_raw.attributes.channels , but trying to pull anything beyond that does not work.

Help!

Edit: solved it! the problem lies with the nested attributes within the rest sensor. This bit of code fixed it for me (note the [2]; this was necessary to tell the template which section to pull the numbers from):

sensors:
      realtime_consumption:
        friendly_name: "Consumption"
        device_class: power
        unit_of_measurement: W
        value_template: "{{ state_attr('sensor.neurio_raw', 'channels')[2].p_W }}"

Just looking to get this working, as I’ve pretty much ignored my neurio sensor since the default plugin failed, but am having some issues getting the sensors to display data. I suspect this is because my 2015 neurio install doesn’t include generation as in your example, so the channels might be wrong (I am of course just trying to create the consumption sensor rather than adding a generation one).

I tried Geoff’s suggestion from above, but that didn’t work for me either.

The results I get directly from the sensor’s current-sample page (with sensorID obfuscated) are:

{"sensorId":"0x000000000001932C","timestamp":"2022-01-09T01:47:12Z","channels":[{"type":"PHASE_A_CONSUMPTION","ch":1,"eImp_Ws":318062520955,"eExp_Ws":35827,"p_W":627,"q_VAR":-379,"v_V":236.487},{"type":"CONSUMPTION","ch":2,"eImp_Ws":318062430880,"eExp_Ws":38,"p_W":627,"q_VAR":-379,"v_V":236.487}],"cts":[{"ct":1,"p_W":627,"q_VAR":-379,"v_V":236.487,"i_A":3.448},{"ct":2,"p_W":0,"q_VAR":0,"v_V":0.205,"i_A":0.000},{"ct":3,"p_W":0,"q_VAR":0,"v_V":0.205,"i_A":0.000},{"ct":4,"p_W":0,"q_VAR":0,"v_V":236.480,"i_A":0.000}]}

Any suggestions as to what the correct format of the Consumption sensor should be?

Here is mine, place it under your top level sensor: in your configuration.yaml

- platform: template

    sensors:

      realtime_consumption:

        friendly_name: "Consumption"

        device_class: power

        unit_of_measurement: W

        value_template: "{{ state_attr('sensor.neurio_raw', 'channels')[2].p_W }}"

Oddly enough, I was having issues getting this working after my HA VM crashed and I had to do restore. For some reason, the rest platform would not setup. Tried again today and it magically worked (formatting error somewhere?). Can confirm this code is working for me now, but do you have the neurio_raw sensor setup? that is where the info gets pulled for this particular sensor, not from the neurio api directly like the neurio_raw does.

Thanks for that, unfortunately that’s exactly what my current configuration is set to :slight_smile:
Yes - as the neurio api no longer works for me I have set up a neurio_raw sensor as per Bobby’s example, and that is working, and providing live info:

Does your neurio_raw sensor look the same as mine? I suspect I’ll just have to play around with the syntax of the sensor until I get it working.

EDIT: Got it working with

      value_template: "{{ (states.sensor.neurio_raw.attributes.channels.1.p_W) }}"

(states.sensor.neurio_raw.attributes.channels.0.p_W) gets me channel 1.

Good to hear you got it! So, it looks like the original formatting worked for you?

I wonder what the difference is between our setups?

I was a Kickstarter backer for neurio back when it released but only recently hooked it back up after moving a couple times. It was offline for a couple years so I wonder if there was an update at one point that I missed out on that changed it somehow?

The difference is the configuration of the CTs (how many) and what data you’re pulling from the sensor. It’s all in JSON format, so depending on how many sensors you have and which data you want, the count of the array you need to reference may be different than what I originally posted.

1 Like

Hi Guys.

Found this thread while searching if it was possible to use my Neurio sensor that I got from Kickstarter long time ago.
Now that Home Assistant added support for energy metering I thought I would try to see if it was possible to use it.

Like user @mist, I also have the 3 Phase model, and was wondering if someone could help make a template that works with this?

Also I noticed in the latest discussion that the original post by @Bobby with all the config might not work with the Energy metering feature and need additional config? or did I miss-understand?

Any help would be great. Thank you.

The output from the 3-phase looks like this:

{"sensorId":"0x0000C47F51018244","timestamp":"2022-02-03T15:00:46Z","channels":[{"type":"PHASE_A_CONSUMPTION","ch":1,"eImp_Ws":40868465475,"eExp_Ws":2380,"p_W":171,"q_VAR":-102,"v_V":233.006},{"type":"PHASE_B_CONSUMPTION","ch":2,"eImp_Ws":58456695160,"eExp_Ws":4111,"p_W":582,"q_VAR":-287,"v_V":233.595},{"type":"PHASE_C_CONSUMPTION","ch":3,"eImp_Ws":13693604379,"eExp_Ws":6972,"p_W":37,"q_VAR":-23,"v_V":234.686},{"type":"CONSUMPTION","ch":4,"eImp_Ws":113017591779,"eExp_Ws":391,"p_W":790,"q_VAR":-412,"v_V":233.762}],"cts":[{"ct":1,"p_W":171,"q_VAR":-102,"v_V":233.006,"i_A":0.947},{"ct":2,"p_W":582,"q_VAR":-287,"v_V":233.595,"i_A":2.823},{"ct":3,"p_W":37,"q_VAR":-23,"v_V":234.686,"i_A":0.206},{"ct":4,"p_W":0,"q_VAR":0,"v_V":233.001,"i_A":0.000}]}

Here is a working version for the 3phase:

sensor:
- platform: rest
  resource: http://YOUR_IP_HERE/current-sample
  name: neurio_raw
  scan_interval: 1
  value_template: '{{ value_json.state }}'
  json_attributes:
    - channels
- platform: template
  scan_interval: 1
  sensors:
    realtime_consumption_a:
      friendly_name: "Consumption A"
      device_class: power
      unit_of_measurement: W
      value_template: "{{ state_attr('sensor.neurio_raw', 'channels')[0].p_W }}"
    realtime_consumption_b:
      friendly_name: "Consumption B"
      device_class: power
      unit_of_measurement: W
      value_template: "{{ state_attr('sensor.neurio_raw', 'channels')[1].p_W }}"
    realtime_consumption_c:
      friendly_name: "Consumption C"
      device_class: power
      unit_of_measurement: W
      value_template: "{{ state_attr('sensor.neurio_raw', 'channels')[2].p_W }}"
    realtime_consumption:
      friendly_name: "Consumption Total"
      device_class: power
      unit_of_measurement: W
      value_template: "{{ state_attr('sensor.neurio_raw', 'channels')[3].p_W }}"
1 Like

I recently bought the Generac PWRcell system and i was hoping to use the local sensors in HA, but i dont get any reply from the URL. Does the local access has been deprecated on the newer versions?

I also have the newer system and can’t seem to get any response from the URL. I tried to scrape the pwrview website but that’s also a mess… any help here would be awesome.

Hey @oriolism and @papacrown , any chance either of you made headway with pwrcell connectivity? My system is being provisioned and I’m curious whether I need to attempt scraping from the inverter or if I’m supposed to be hitting a rebus beacon address instead. Curious for details if either of you might have some updates! Thanks.

Check this project:

1 Like

Any chance you’d mind discussing strategies for implementation? My discord is AdmiralPete#9678 if you’re in the homeassistant server.

So I am a sensor noob and I am trying to get this up and running with my Neurio. I’m not entirely fluent in some of the syntax of the parsing for the templates so apologies for the basic requests. If I take my JSON from the neurio and use the template editor to parse my data I get the following:

 set my_test_json = {
    "sensorId": "0x0000C47F51019B45",
    "timestamp": "2023-11-07T03:00:23Z",
    "channels": [
        {
            "type": "PHASE_A_CONSUMPTION",
            "ch": 1,
            "eImp_Ws": 236424866152,
            "eExp_Ws": 543326,
            "p_W": 203,
            "q_VAR": -38,
            "v_V": 123.345
        },
        {
            "type": "PHASE_B_CONSUMPTION",
            "ch": 2,
            "eImp_Ws": 271237108623,
            "eExp_Ws": 2272310,
            "p_W": 1177,
            "q_VAR": -96,
            "v_V": 123.876
        },
        {
            "type": "CONSUMPTION",
            "ch": 3,
            "eImp_Ws": 499067562247,
            "eExp_Ws": 3066363462,
            "p_W": 1380,
            "q_VAR": -134,
            "v_V": 123.61
        }
    ],
    "cts": [
        {
            "ct": 1,
            "p_W": 203,
            "q_VAR": -38,
            "v_V": 123.345,
            "i_A": 1.766
        },
        {
            "ct": 2,
            "p_W": 1177,
            "q_VAR": -96,
            "v_V": 123.876,
            "i_A": 9.833
        },
        {
            "ct": 3,
            "p_W": 0,
            "q_VAR": 0,
            "v_V": 123.862,
            "i_A": 0
        },
        {
            "ct": 4,
            "p_W": 0,
            "q_VAR": 0,
            "v_V": 123.335,
            "i_A": 0
        }
    ]
} %}

The consumption is {{ my_test_json.channels[2].p_W}}.

This template correctly returns the field for the total consumption.

From the discussion above, I’ve included the following code in my configuration yaml file:

#Try to add local Neurio Sensor
sensor:
  - platform: rest
    resource: http://192.168.86.118/current-sample
    name: neurio_raw
    scan_interval: 1
    value_template: '{{ value_json.state }}'
    json_attributes:
        - channels
  - platform: template
    scan_interval: 1
    sensors:
      realtime_consumption:
      friendly_name: "Consumption Total"
      device_class: power
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.2.p_W }}"

For the value_template field I’ve tried almost all the syntax I found in the discussion above including:

  value_template: "{{ state_attr('sensor.neurio_raw', 'channels')[2].p_W }}"

I can see the neurio_raw sensor loaded in the entities section and if I expand it I get the live sensor data JSON:

When I include the code for the realtime consumption sensor I get an error in the log file about unable to iterate on a NONE object. So I assume that means the sensor.neurio_raw object from the prior block isn’t valid.

I can’t seem to extract that channel data into the template sensors despite all my efforts. Any help appreciated!

----Edit Solved------
Looks like an YAML indentation issue in the template section got me. I was able to get it fixed but I can’t use the sensor in the default energy dashboard. I’ll keep working that.

Hi @superbad_dad - were you ever able to get this working in the Energy Dashboard?

I have Neurio (local) working with the Home Assistant Energy Dashboard. Thanks to @Bobby for the code above. I ended up added 3 new variables that match what I think HA Energy Dashboard is looking for and to make it easier to match them up, I used the exact same names. I may have misunderstood what HA was looking for, but these are my assumptions:

return_to_grid_neurio

  • total kWh pushed to the grid, expressed as a positive number
  • this is derived from Net Consumption (calculated_net).
    • If calculated_net is positive, then it equals calculated_net, else 0.
      grid_consumption_neurio
  • total kWh pulled from the grid, expressed as a positive number
  • this is derived from Net Consumption (calculated_net).
    • If calculated_net is negative, then it equals abs(calculated_net), else 0.
      solar_production_neurio
  • total kWh produced by solar, expressed as a positive number
  • this is the exact same as Daily Generation (calculated_generation)
  • created only to make adding to HA Energy Dashboard simple

My system:
Neurio 2-phase + solar CTs, Firmware Version: 1.7.0
Home Assistant Details:

  • Core2023.11.3
  • Supervisor2023.11.6
  • Operating System11.1
  • Frontend20231030.2

Here are a list of the changes I made:

Added the following to: /homeassistant/automations.yaml

- id: '1586370303877'
  alias: Set start of day Generation
  description: ''
  trigger:
  - at: '23:59:30'
    platform: time
  condition: []
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.generation_at_midnight
      value: "{{ states('sensor.generation_imported') | float }}"
- id: '1586382750599'
  alias: Set start of day Consumption
  description: ''
  trigger:
  - at: '23:59:30'
    platform: time
  condition: []
  action:
    service: input_number.set_value
    data_template:
      entity_id: input_number.consumption_at_midnight
      value: "{{ states('sensor.consumption_imported') | float }}"

Created /homeassistant/customize.yaml, and added the following to:

sensor.calculated_generation:
  icon: mdi:solar-power
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.calculated_consumption:
  icon: mdi:transmission-tower
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.calculated_net:
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.grid_consumption_neurio:
  icon: mdi:transmission-tower
  state_class: total_increasing
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.return_to_grid_neurio:
  icon: mdi:home-export-outline
  state_class: total_increasing
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.solar_production_neurio:
  icon: mdi:solar-power
  state_class: total_increasing
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy

Added the following to: /homeassistant/configuration.yaml

homeassistant:
  customize: !include customize.yaml

input_number:
  generation_at_midnight:
    min: 0
    max: 9999999999999
  consumption_at_midnight:
    min: 0
    max: 9999999999999
  net_at_midnight:
    min: 0
    max: 9999999999999

sensor:
- platform: rest
  resource: http://10.0.0.200/current-sample
  name: neurio_raw
  scan_interval: 1
  value_template: '{{ value_json.state }}'
  json_attributes:
    - channels
- platform: template
  scan_interval: 1
  sensors:
    energy_flow:
      #Not necessary, but I like this for my Grafana graphs
      unit_of_measurement: W
      value_template: "{{ (states.sensor.realtime_consumption.state | int) - (states.sensor.realtime_solar_gen.state | int) }}"
    pwr_avail:
      #Not necessary, but I like this for my Grafana graphs
      unit_of_measurement: W
      friendly_name: Free Solar Power
      value_template: "{{ (states.sensor.realtime_solar_gen.state | int) - (states.sensor.realtime_consumption.state | int) }}"
    realtime_solar_gen:
      friendly_name: 'Generation'
      device_class: power
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.3.p_W }}"
    realtime_consumption:
      friendly_name: 'Consumption'
      device_class: power
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.4.p_W }}"
    net_exported:
      #Not necessary, but I may find a use for this later
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.2.eExp_Ws }}"
    net_imported:
      #Not necessary, but I may find a use for this later
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.2.eImp_Ws }}"
    generation_exported:
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.3.eExp_Ws }}"
    generation_imported:
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.3.eImp_Ws }}"
    consumption_exported:
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.4.eExp_Ws }}"
    consumption_imported:
      unit_of_measurement: W
      value_template: "{{ states.sensor.neurio_raw.attributes.channels.4.eImp_Ws }}"
    calculated_consumption:
      friendly_name: 'Daily Consumption'
      unit_of_measurement: 'kWh'
      value_template: "{{ ((states('sensor.consumption_imported') | float - states('input_number.consumption_at_midnight') | float) / 3600000) | round(2) }}"
    calculated_generation:
      friendly_name: 'Daily Generation'
      unit_of_measurement: 'kWh'
      value_template: "{{ ((states('sensor.generation_imported') | float - states('input_number.generation_at_midnight') | float) / 3600000) | round(2) }}"
    calculated_net:
      friendly_name: 'Net Consumption'
      unit_of_measurement: 'kWh'
      value_template: "{{ (states('sensor.calculated_consumption') | float - states('sensor.calculated_generation') | float) | round(2) }}"
    grid_consumption_neurio:
      friendly_name: 'Grid Consumption (Neurio)'
      unit_of_measurement: 'kWh'
      value_template: "{{ max(states('sensor.calculated_net') | float, 0) | default(0)}}"
    return_to_grid_neurio:
      friendly_name: 'Return to Grid (Neurio)'
      unit_of_measurement: 'kWh'
      value_template: "{{ min(states('sensor.calculated_net') | float, 0) | abs | default(0)}}"
    solar_production_neurio:
      friendly_name: 'Solar Production (Neurio)'
      unit_of_measurement: 'kWh'
      value_template: "{{ (states('sensor.calculated_generation'))  }}"

When I add the platform rest and template sections from the above code, I get the following config yaml errors. Any suggestions or is this simply a formatting issue?

Configuration warnings
Integration error: value_template - Integration 'value_template' not found.
Integration error: resource - Integration 'resource' not found.
Integration error: name - Integration 'name' not found.
Integration error: sensors - Integration 'sensors' not found.
Integration error: platform - Integration 'platform' not found.
Integration error: source - Integration 'source' not found.
Integration error: scan_interval - Integration 'scan_interval' not found.
Integration error: json_attributes - Integration 'json_attributes' not found.

@Bobby @scottdog123

I am running into the same issues as @mainwater. Is there some formatting that I need to update to get this working with a newer instances of HA? Any help is appreciated.