lolouk44 / CurrentCost_HA_CC

CurrentCost Meter Reading Custom Component for Home Assistant
16 stars 7 forks source link

Meter Reading #2

Closed xion2000 closed 4 years ago

xion2000 commented 4 years ago

In the days when Current Cost hosted a web service to upload the data collected using their equipment is was possible to display a meter reading for Gas & Elec (and water if you had one I think) is it possible to extract some data then calibrate a figure to correspond with your physical meter reading.

lolouk44 commented 4 years ago

I actually don't need to write a script for you as I had already set the correct logging level on the custom component. All you need to do is to set your currentcost logging level to debug. Add these lines to your configuration.yaml:

logger:
  default: error
  logs:
    custom_components.currentcost: debug

then send me the logs for a few lines Make sure you remove this quickly else your log file will fill up like crazy

xion2000 commented 4 years ago

home-assistant.log

lolouk44 commented 4 years ago

Thanks. Can you confirm for each appliance/page number:

xion2000 commented 4 years ago

Current Cost Equipment Setup for Home Assistant (GitHub Post).docx

lolouk44 commented 4 years ago

blimey that's some setup you got there. I think I can get that data out. Can you try and replace the sensor.py file in [config]/custom_components/currentcost with this one and let me know if it gives you what you expect? sensor.zip

xion2000 commented 4 years ago

Sorry for the delay in getting back to you I've been double checking everything as I wasn't sure if both my EnviR's were setup the same. This is a slightly amended document.

Current Cost Equipment Setup for Home Assistant (GitHub Post).docx

I have 2 EnviR's in use, 1 connected to a PC and the other connected to my Pi. The entries using IAM's (Individual Appliance Monitors) are not really important for this setup as I can do what they do with smart plugs (flashed with tasmota)

lolouk44 commented 4 years ago

that's fine, just list the appliances that you want to monitor in HA I see you selected all appliances between 1 and 8. What I do need to know is whether the updated sensor.py work, especially for meters with impulse please

xion2000 commented 4 years ago

Screen grad attached CurrentCost Looks VERY promising (I think!!) Thanks very much, I'm sadly quite excited about this as its something I'm very interested in (I monitor energy usage & solar production closely) I've had the Current Cost equipment in use for many years but lost some of its uses a few years ago when their website for logging the data closed down. I have 3 different solar systems running (1 official that I get paid for - Garage Solar, 1 grid tied I don't get paid for - Shed Solar and a new DC only system - DC Solar I'm using to power 2 small computers) I really appreciate this work you are doing as I believe its outside of my capability.

lolouk44 commented 4 years ago

so it looks like you're listing too many appliances as 7, 8 and 9 show as null I've made a small change so return only the value for imp and IPU. I'll also rename them slightly. Suggested names: Imp --> Impulses IPU --> Impulses/Unit

If you can confirm, I'll send a revised version

When you say it looks promising, is there anything that's missing or incorrect?

xion2000 commented 4 years ago

I said promising as I presume to work out if the METER figures are working correctly I'll need to manually adjust the extracted number with my actual meter reading, do you know how I can do that Any idea why the order of the Appliances is a bit out I'll remove a couple of entries then get back in touch but I assumed the null entry was because its the DATA side of each meter, each meter sends out 2 streams the DATA one is just an ever increasing count I think.

xion2000 commented 4 years ago

Yes send an updated file if you believe its still required, I'm a little out of my depth here so please bear with me

lolouk44 commented 4 years ago

ok, for the meter figures, if any adjustment needs to be made (like the temperature for example), this should be done in HA via the template sensor, as each user may need a different adjustment. I'm only returning the data that I get from the data stream. See if the data shows up correctly with this latest version sensor.zip Changes / points to check:

xion2000 commented 4 years ago

Yes I too am only returning the data from the data stream.

CurrentCost2

CurrentCost Elec Meter

Do I need to change anything in my configuration.yaml?

lolouk44 commented 4 years ago

so the data shows up nicely now. You need to start creating template_sensors, for example:

  - platform: template
    sensors:
      currentcost_temperature:
        entity_id: sensor.current_cost
        unit_of_measurement: '°C'
        value_template: '{{ state_attr("sensor.current_cost", "Temperature")[:-3] | float  }}'
        friendly_name: CurrentCost Temperature
      currentcost_power:
        entity_id: sensor.current_cost
        unit_of_measurement: 'W'
        value_template: '{{ state_attr("sensor.current_cost", "Appliance 0")[:-2] | int  }}'
        friendly_name: CurrentCost Power
      dehumidifier_power:
        entity_id: sensor.current_cost
        unit_of_measurement: 'W'
        value_template: '{{ state_attr("sensor.current_cost", "Appliance 2")[:-2] | int  }}'
        friendly_name: Dehumidifier Power
xion2000 commented 4 years ago

Even though I've removes Appliances 2, 3, 5 & 6, 2,6 & 3 are still showing up in the entity list (in that order). I'd already tied creating some template sensors but they are not working for the Impulses

xion2000 commented 4 years ago

Can you see what I'm doing wrong?

Apologies, I've forgotten how to post it so it formats it correctly

sensor 8:

lolouk44 commented 4 years ago

If you're listing all appliances under devices, they'll all show up. Only list the ones you want to keep, e.g. devices:

only use [:-2] for attributes that have a unit (e.g. W) Appliances with impulse should not have the trim [:-2]

xion2000 commented 4 years ago

I had edited the list to only have the devices I wanted but the ones I removed were still showing up but not in numerical order, so I put my full list back and they went back to the correct numerical order.

lolouk44 commented 4 years ago

you will need to restart your instance of HA for the attributes to be reset

xion2000 commented 4 years ago

Every time I change something I restart HA (after I check the config) I think I've worked out my mistakes for the Meters, I'll get back to you shortly. Cheers

xion2000 commented 4 years ago

All working now!! How can I edit the meter reading to only display a certain number of decimal places

lolouk44 commented 4 years ago

use the float and round filters: '{{ state_attr("sensor.current_cost", "Temperature")[:-3] | float | round (2)}}'

xion2000 commented 4 years ago

You really are a star! I'll give it a try

lolouk44 commented 4 years ago

Cool. I'll now close this issue since I've added the additional data which is what it was all about :)