Support for Local Neurio Power Sensor

Has anyone created a Hass.io plugin for the Neurio local sensor? I know that there is support for the Neur.io service but I like to keep things local and not dependent on cloud services if at all possible.

All of the information is available on the local sensor and the cloud service seem less than useful these days. If no one has created a local sensor can I get pointers on how to create one of my own? This device has a webpage on the local net that provides JSON output.

The JSON format looks like this:

// 20180922092493
// http://192.168.10.9/current-sample

{
  "sensorId": "0x0000C47F51019B7D",
  "timestamp": "2018-09-22T13:28:31Z",
  "channels": [
    {
      "type": "PHASE_A_CONSUMPTION",
      "ch": 1,
      "eImp_Ws": 119434880724,
      "eExp_Ws": 23,
      "p_W": 645,
      "q_VAR": 79,
      "v_V": 123.087
    },
    {
      "type": "PHASE_B_CONSUMPTION",
      "ch": 2,
      "eImp_Ws": 130301420433,
      "eExp_Ws": 23,
      "p_W": 918,
      "q_VAR": -16,
      "v_V": 122.051
    },
    {
      "type": "CONSUMPTION",
      "ch": 3,
      "eImp_Ws": 249736301446,
      "eExp_Ws": 41,
      "p_W": 1563,
      "q_VAR": 63,
      "v_V": 122.569
    }
  ],
  "cts": [
    {
      "ct": 1,
      "p_W": 645,
      "q_VAR": 79,
      "v_V": 123.087
    },
    {
      "ct": 2,
      "p_W": 918,
      "q_VAR": -16,
      "v_V": 122.051
    },
    {
      "ct": 3,
      "p_W": 0,
      "q_VAR": 0,
      "v_V": 0.000
    },
    {
      "ct": 4,
      "p_W": 0,
      "q_VAR": 0,
      "v_V": 123.080
    }
  ]
}
3 Likes

Did anything come of this? I’m interested. Love to keep things local

Never heard back from anyone.

My understanding is that web pages can be used as sensors and this one is well formatted for exactly that. I’ll admit I haven’t looked very hard but an example of someone doing that would hopefully get me going. I’d have to understand the JSON parsing as well, but that seems more straightforward.

Completely agree on keeping things local. I just put in a Rheem water heater and there’s no way (that I know of) to get information from it on the local network. You must go to the cloud provider. And they don’t provide one of the things I’d like to see most, is the water heater on or off?

The library used for the cloud based sensor in home assistant also supports querying the local usage. The method is get_local_current_sample and you can see its unit test here. Neurio documents the local API as well.

So, overall it should be pretty easy to add a local IP configuration parameter to the neurio sensor and add local usage.

2 Likes

Thank you!

I have been using Rheem/Econet for about 6 months with HA. It has been pretty reliable until about a week ago when something changed. It is back now and working. However, it is open ended commands only thru their cloud AFAIK.

One of these days IoT items are going to crash, just pick a reason, and there are going to be a lot of people crying. Not sure why it seems to be an ignored issue by most.

Thanks for this. I hope to be able to implement.

bump would be interested too

You don’t need a plug in, just create a sensor pulling json variables from a rest sensor.

  - platform: rest
    resource: http://192.168.1.145/current-sample
    name: neurio_raw
    scan_interval: 1
    value_template: '{{ value_json.state }}'
    json_attributes:
      - channels
      - channels.3.p_W

Then create some sensors from those:

  - platform: template
    scan_interval: 1
    sensors:
      energy_flow:
        unit_of_measurement: W
        value_template: "{{ (states.sensor.realtime_consumption.state | int) - (states.sensor.realtime_solar_gen.state | int) }}"
      pwr_avail:
        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: 'Solar Generation (Raw)'
        device_class: power
        unit_of_measurement: W
        value_template: "{{ states.sensor.neurio_raw.attributes.channels.3.p_W }}"
      realtime_consumption:
        friendly_name: 'Consumption (Raw, corrected)'
        device_class: power
        unit_of_measurement: W
        value_template: "{{ (states.sensor.neurio_raw.attributes.channels.4.p_W + 280) }}"
2 Likes

By the way, if anyone wants to generate all this data locally and not rely on the server’s database to generate some real time states, I’ve created a few sensors to do all that. This way you won’t be hammering the remote API (far more efficient than the official component or the custom one I created). See code and instructions below to create all these sensors.

You’ll need:

  • A rest sensor to pull the local api data
  • Sensors for each attribute pulled from the local API rest sensor
  • input_numbers to store data to calculate daily usage
  • Automations to store data to the input numbers each night around midnight

Sensors:

- platform: rest
  resource: http://YOUR-NEURIO-IP-ADDRESS/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) }}"

Then the input_numbers:

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

And finally, the automations:

- 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 }}"

Once you’ve got it all setup and bringing in the data properly, just set up a card in lovelace.

image

The official component could probably be updated to do all this and then you wouldn’t have all this messy YAML in your configs. Last time I tried to update the official component I was met with nothing but friction from the brass. Sorry for hijacking the thread, good luck!

2 Likes

So I tried to create an API key, but not sure what the supposedly optional Homepage URL is.

Perhaps I’ll try this local method.

@HomeBee You can use basically any URL for the homepage…

I use “https://home-assistant.io/components/sensor.neurio_energy/

However, As of July 26 (when I got a random email from PWRView saying my account had been added??), it seems my API keys no longer work with the neurio site… I get an error back from their API endpoint:

{'status': 403, 'code': 'insufficient_permissions', 'message': 'The user associated with the access token provided does not have sufficient permissions to make this request.'}

I’m thinking of trying @Bobby’s method as a workaround

Thanks Bobby - complete noob here. Does this code go into configuration.yaml or somewhere else?

The sensors go under sensors in configuation.yaml.

input_number is top level yaml that goes in configuration.yaml.

Automations go in the automation yaml file.

If you need help rgtoth, you can hit me up on discord. Bobby#7255

Thanks Bobby! I’ll give it a try and let you know if I run into any issues

Hi,

Can we have a template with support for 3phase? I tried adding it but all the values are appearing in the wrong sensors

Here is my current-sample

{"sensorId":"xxxxxx","timestamp":"2021-02-22T13:58:57Z","channels":[{"type":"PHASE_A_CONSUMPTION","ch":1,"eImp_Ws":124707194330,"eExp_Ws":47917930,"p_W":117,"q_VAR":8,"v_V":223.282},{"type":"PHASE_B_CONSUMPTION","ch":2,"eImp_Ws":41699245042,"eExp_Ws":15082072,"p_W":215,"q_VAR":-51,"v_V":221.876},{"type":"PHASE_C_CONSUMPTION","ch":3,"eImp_Ws":25777369701,"eExp_Ws":20643,"p_W":465,"q_VAR":243,"v_V":224.981},{"type":"CONSUMPTION","ch":4,"eImp_Ws":192182749362,"eExp_Ws":62297922,"p_W":798,"q_VAR":200,"v_V":223.380}],"cts":[{"ct":1,"p_W":215,"q_VAR":-51,"v_V":221.876,"i_A":1.090},{"ct":2,"p_W":117,"q_VAR":8,"v_V":223.282,"i_A":0.563},{"ct":3,"p_W":465,"q_VAR":243,"v_V":224.981,"i_A":2.490},{"ct":4,"p_W":0,"q_VAR":0,"v_V":221.856,"i_A":0.000}]}

/David

I’ve been using this and it’s been great. Especially, since it looks like Generic has depreciated their API support.

Question: Can we incorporate YAML that would expose these sensors to the new HA Energy Management features?

1 Like

Probably. Something I’ll look into when I get settled after moving next week some time. Maybe this week if I get some free time to really look into how to integrate this.

1 Like

I’m testing a few things now. Won’t know if the data generated is correct for a few days, but here’s what I put in my customize.yaml file to make my entities selectable on the energy page.

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

Great news.

I’m out of pocket right now but I’ll give this a try when I return. I need to read more about the Energy Management feature. Right now, all I have feeding into it is my Tesla charging current. For some reason, after showing reasonable numbers when the car is charging, it starts showing small returns to the utility when, in fact, it’s just sitting quietly not taking any current and certainly not returning any.

I have some reading to do. Thanks for putting this up so quickly.