What script? I use the dsmr component and a basic daily automation with a curl command. You can have a look at my repo, link in my profile.
I’m trying to migrate from Domoticz to HA. I’m capable of reading out the smart meter also with HA but it seems this component is missing to types of data compared to the Domoticz plugin. In the Domoticz plugin I also have these sensors available:
- Total consumption today
- Total production today
Is there anyway to, for instance create a template sensor, to calculate these values?
I have made some modifications to the plugin code to keep it a little more quiet. A whole bunch of sensors updated literally every second really starts clogging up the homeassistant database resulting in a nearly unusable events/states mechanism (86400 state changes a day is a bit much). For now I’ve hacked in a filter that only allows messages coming in on the 20th and 50th second each minute (so update rate is reduced to twice a minute). There are probably better ways to do this but it works for me and I have not found a real place where this plugin is maintained
All changes need to be done in /srv/homeassistant/lib/python3.6/site-packages/dsmr_parser/clients/protocol.py:
At the top of the file add import datetime
.
My new handle_telegram function looks like this:
`def handle_telegram(self, telegram):
“”“Send off parsed telegram to handling callback.”""
allowedseconds = [20, 50]
now = datetime.datetime.now()
if now.second in allowedseconds:
self.log.debug('got telegram: %s', telegram)
try:
parsed_telegram = self.telegram_parser.parse(telegram)
except InvalidChecksumError as e:
self.log.warning(str(e))
except ParseError:
self.log.exception("failed to parse telegram")
else:
self.telegram_callback(parsed_telegram)
else:
self.log.debug('skipping since second %d is not in allowedseconds', now.second)`
I’m willing to cobble together some decent configuration options but I’m unsure where to submit those.
I’ve got the same problem that my InfluxDB is flouded with state changes (DSMR version 5).
On my hassio installation, on a Raspberry Pi 3, I’m not able to find the path via SSH: /srv/homeassistant/lib/python3.6/site-packages/dsmr_parser/clients/protocol.py
Is it possible to make this change on hassio?
Yo could add a template sensor that is updated less frequently and save that instead of the ‘real’ sensor value.
Thanks for your quick reply. But when I check the component page for Template Sensor (https://www.home-assistant.io/components/sensor.template/), I don’t se a option for a interval.
Do I miss something?
I’ve solved it by creating a Custom_Component (config\custom_components\sensor\dsmr_custom.py in my config folder). I copied the original dsmr.py from github (https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/sensor/dsmr.py) and changed:
def update_entities_telegram(telegram):
"""Update entities with latest telegram and trigger state update."""
# Make all device entities aware of new telegram
for device in devices:
device.telegram = telegram
hass.async_create_task(device.async_update_ha_state())
with the following:
def update_entities_telegram(telegram):
"""Update entities with latest telegram and trigger state update."""
# Make all device entities aware of new telegram
allowedseconds = [20, 50]
now = datetime.datetime.now()
if now.second in allowedseconds:
for device in devices:
device.telegram = telegram
hass.async_create_task(device.async_update_ha_state())
else:
self.log.debug('skipping since second is not in allowedseconds',
now.second)
Borrowed some code from @dotms
Now my sensor inside hassio is updating itself every 30 seconds and my database is not getting flooded.
Did you finally get it working? Because I’m trying the same setup and it is not working as excepted.
here my setting for the P1 smart meter in Hassio raspberry pi 2
Example configuration.yaml entry for USB/serial connected Smartmeter
sensor:
- platform: dsmr
port: /dev/ttyUSB0
dsmr_version: 2.2
group:
meter_readings:
name: Meter readings
entities:
- sensor.power_consumption_low
- sensor.power_consumption_normal
- sensor.gas_consumption