Closed xion2000 closed 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
Thanks. Can you confirm for each appliance/page number:
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
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)
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
Screen grad attached
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.
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?
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.
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
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:
Yes I too am only returning the data from the data stream.
Do I need to change anything in my configuration.yaml?
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
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
Can you see what I'm doing wrong?
Apologies, I've forgotten how to post it so it formats it correctly
sensor 8:
platform: currentcost serial_port: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0 name: Current Cost baudrate: 57600 devices:
platform: template
sensors:
currentcost_temperature:
entity_id: sensor.current_cost
unit_of_measurement: '°C'
value_template: '{{ state_attr("sensor.current_cost", "Temperature")[:-3] | float -3 }}'
friendly_name: CurrentCost Temperature
currentcost_electricity:
entity_id: sensor.current_cost
unit_of_measurement: 'W'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 0")[:-2] }}'
friendly_name: CurrentCost Electricity
currentcost_garage_solar:
entity_id: sensor.current_cost
unit_of_measurement: 'W'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 1")[:-2] }}'
friendly_name: CurrentCost Garage Solar
currentcost_iam1:
entity_id: sensor.current_cost
unit_of_measurement: 'W'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 2")[:-2] }}'
friendly_name: CurrentCost IAM1
currentcost_iam2:
entity_id: sensor.current_cost
unit_of_measurement: 'W'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 3")[:-2] }}'
friendly_name: CurrentCost IAM2
currentcost_gas:
entity_id: sensor.current_cost
unit_of_measurement: 'W'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 4")[:-2] }}'
friendly_name: CurrentCost Gas
currentcost_iam3:
entity_id: sensor.current_cost
unit_of_measurement: 'W'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 5")[:-2] }}'
friendly_name: CurrentCost IAM3
currentcost_iam4:
entity_id: sensor.current_cost
unit_of_measurement: 'W'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 6")[:-2] }}'
friendly_name: CurrentCost IAM4
currentcost_elec_meter:
entity_id: sensor.current_cost
unit_of_measurement: 'kWh'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 7")[:-2] }}'
friendly_name: CurrentCost Elec Meter
currentcost_gas_meter:
entity_id: sensor.current_cost
unit_of_measurement: 'kWh'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 8")[:-2] }}'
friendly_name: CurrentCost Gas Meter
currentcost_pv_meter:
entity_id: sensor.current_cost
unit_of_measurement: 'kWh'
value_template: '{{ state_attr("sensor.current_cost", "Appliance 9")[:-2] }}'
friendly_name: CurrentCost PV Meter
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]
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.
you will need to restart your instance of HA for the attributes to be reset
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
All working now!! How can I edit the meter reading to only display a certain number of decimal places
use the float
and round
filters:
'{{ state_attr("sensor.current_cost", "Temperature")[:-3] | float | round (2)}}'
You really are a star! I'll give it a try
Cool. I'll now close this issue since I've added the additional data which is what it was all about :)
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.