I guess the only other thing to do is to run HA with all logs set to debug to see if you get something.
What’s your setup?
VM? Docker? Pi?
I have found the same thing, with debug turned on for the component it doesnt fail (thats why I havent responded as Ive been waiting for it to fail)
Thanks. I’m check the code again but as far as I remember the debug only adds to the logs…
@Moomimtrolly @aumatt
Do you use another serial based device or the serial component by chance?
@aumatt
What’s your setup?
VM? Docker? Pi?
I’ve copied the serial component and just added some calculations to the received data to format it so still don’t understand why it fails within 24h
Out of interest are you able to set the serial component on port 57600 and see if it runs for more than 24h? (doesn’t matter what the returned data is at this point)
No other serial devices, current cost the only one.
I did check for error messages in dmesg, but there are none.
Just looking back for when it stops…
This one stopped at midnight!
I’ll check other days
midnight exactly… mmm a bit too much of a coincidence I’d say.
Depending on what you use… could something else be firing up at midnight ? It’s a popular if unwise time for cron jobs. If you can ssh in to your computing box (outside HA), what does the cron list show (crontab -l) show ?
No other serial devices for me either, Im running HASS.IO on a VM.
My Current config is
- platform: currentcost
serial_port: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0
name: Current Cost
baudrate: 57600
devices:
- 0
- 1
- 9
Actually dont know why I have appliance 9 turned on for tbh.
crontab empty.
It does fail during the day but sometimes for just a hour or less but mainly at midnight.
Unfortunately I wasn’t keeping a log on when it stopped and when I rebooted.
The last time it stopped was yesterday 06.05.2020 @ 09:00 and came back at 14:00, not sure it was me rebooting.Still going since then. Weird it’s on the hour.
OK not a user crontab. How about a system crontab ?
sudo crontab -l
Mine just failed after quite a few days of sustained operation. no errors just stops. I disconnected the USB from the VM, fired up putty to see if it was my CurrentCost unit not transmitting but i was still receiving data from the currentcost. Reconnected the USB to the VM, Ill wait a bit to see if the component fires up again.
Matt
no crontab for root was the response.
Funnily instead of just rebooting HA, I decided to reboot the Pi on Thursday afternoon.
Since then it hasn’t lost connection.
The only weird thing is the power is constant just the temp thats drops out now and again.
This is in the history view.
I can live with this, while I’m trying to get Hass.io running on my Pi4 on SSD!
Wow, what are you doing to get those 8 kW bumps in power consumption ? I’m glad I’m not paying your bill
If I recall correctly from my pre-HA days of running my own code, power and temperature come across in the same “message” from the CurrentCost device, so both measurements should arrive or fail at the same time. I suppose the CurrentCost device could have become confused (and appreciate a power cycle) although my unit has been reliable for over a decade.
It’s just the electric shower in the bathroom, I do like the skyline it makes.
I hooked up my current cost as I’d bought an EV and wanted to track charging it until our smart meter is installed. That was the plan before covid. It’s much worse than a shower at 8kW for 6 minutes more like 7kW for 6 hours, cheaper than petrol though!
I did wonder if the issue before could have been a lost connection from the transmitter.
Thanks for all your help.
Just a quick update, server reboot seems to have done the trick. Working fine every since.Thanks for developing this and all the help from everyone. I do like the sky line it makes.
Feedback welcome
I followed the instructions and it went very well, pretty much working first time (unusual for HA projects in my experience )
I got it working in a HA (core) docker instance. When I plugged in the CurrentCost cable into the host, I saw in dmesg that it was /dev/ttyUSB0.
Then in docker-compose.yaml I passed through that device to the HA container. After that it was plain sailing with your instructions. And a quick lovelace graph card, then a quick graph in Grafana, all sorted.
So many thanks for your work, much appreciated!
First of all, very good job with the integration for the current cost, I tested with a Envi model with hassio in a Raspberry Pi 3b+ and it works!!!.
But now I moved the Envi to another instance of home assistant running in a FreeBSD jail running home assistant, I changed the serial port but the rest of the configuration is the same that the configurarion in the raspberry and I get the following errors:
‘’’
2020-09-06 09:37:49 DEBUG (MainThread) [custom_components.currentcost.sensor] Line Received: CC128-v0.110287722:31:4724.8000077100772
2020-09-06 09:37:49 DEBUG (MainThread) [custom_components.currentcost.sensor] Line Received: CC128-v0.110287722:31:5324.80
2020-09-06 09:37:49 ERROR (MainThread) [custom_components.currentcost.sensor] Error parsing data from serial port: CC128-v0.110287722:31:5324.80
2020-09-06 09:37:54 DEBUG (MainThread) [custom_components.currentcost.sensor] Line Received: /CC128-v0.110287722:32:2924.8000077100551
2020-09-06 09:37:54 ERROR (MainThread) [custom_components.currentcost.sensor] Error parsing data from serial port: /CC128-v0.110287722:32:2924.8000077100551
2020-09-06 09:37:55 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.currentcost_power1 fails
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py”, line 263, in async_update_ha_state
await self.async_device_update()
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py”, line 454, in async_device_update
await self.async_update() # type: ignore
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/template/sensor.py”, line 235, in async_update
self._state = self._template.async_render()
File “/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/template.py”, line 230, in async_render
return compiled.render(kwargs).strip()
File “/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py”, line 1090, in render
self.environment.handle_exception()
File “/srv/homeassistant/lib/python3.7/site-packages/jinja2/environment.py”, line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File “/srv/homeassistant/lib/python3.7/site-packages/jinja2/_compat.py”, line 28, in reraise
raise value.with_traceback(tb)
File “”, line 1, in top-level template code
TypeError: ‘NoneType’ object is not subscriptable
‘’’
and get the same error for each appliance (appliance 0, and temperature doesn’t raise an error) when they are not connected to any socket, so I discovered that now my applance sensors are disconnected, I plugged the sensors and the error dissapeared. Maybe you can improve the component handling this situation preventing to raise an error to the home assistant log or raise your custom error indicating that this appliace is missing.
In any case great job.
Thanks for the feedback.
which appliances are you using?
This error occurs when parsing the read data.
I’ve made a small edit to the code to catch the error and prevent further manipulations if the data can’t be parsed, and I’ve adjusted the error message as well…
I’ll post a note once I’ve tested and uploaded the new code on my repo
Thanks for your fast response and your support improving the component.
At this moment I’m using a dishwasher, a refrigerator and a washing machine as appliances via current cost IAM’s.