Can you share your dsmr_custom.py file? please?
Thanks already
Can you share your dsmr_custom.py file? please?
Thanks already
When I use the DSMR sensor, my whole HA freezes after a day or two. I’ve already tried all suggestions in this thread, so I am glad it finally works:)
hmm I don’t have any freezing issues with my HA and DSMR (v5) running in docker on raspberry pi 3b+
After trying Domoticz and Openhab ended by Home Assistant and I love it, easy in use, flexible, nice UI and running perfect on my Synology NAS in docker. Connected to P1 of Kaifa MA105A, and it shows all the data. Tha all sounds perfect, BUT (as some people already mentioned) I want to see daily (weekly) usage/production (Domoticz did it out of the box). Anyone achieved it? Can it be done by some script/rule, so on every event something like “todayUsage = eventT1 - usageT1[date.today(00:00)] + eventT2 - usageT2[date.today(00:00)]” and store it somewhere? sorry I am new in HA and don’t have python knowledge
I use the sqlite sql sensor for this
sensor:
- platforms: sql
queries:
- name: energy_consumption
query: >
SELECT SUM(state) AS 'value'
FROM (
SELECT ROUND(MAX(state) - MIN(state),3) AS state
FROM states
WHERE (entity_id = 'sensor.power_consumption_low' or entity_id = 'sensor.power_consumption_normal')
AND state != 'unknown'
AND state != ''
AND DATE(last_updated) = DATE('now')
GROUP BY entity_id
)t;
column: 'value'
unit_of_measurement: 'kWh'
I use influxdb and grafana for long term statistics but the solution is far from perfect. Domoticz had a great history view of powerusage (also from powersockets).
I use influxdb as the default history database is inefficient and crashing HA if you store more than a few days of data in it. Even if you setup mysql or mariadb as external database.
I created three separate sensors to store the 00:00 values of energy low/high and gas usage to calculate/show the daily usage.
found the setup in this topic:
so you store all events in SQL database and then just query sum for all events of today? I hoped it can be done without external database. Is it limitation of HA or component? In other words can we create feature request in components repo so they can implement it?
This is the standard hass recorder db. I don’t log it into influx, only the dmsr values. I needed this for the lovelace power wheel card.
https://github.com/gurbyz/custom-cards-lovelace/tree/master/power-wheel-card
There is just a simple calculation, max minus min consumption for that day so no sum of all states as you record the total power you used untill then.
You can always request new features. If there is a big community supporting that request chance is higher that it will be implemented soon. Or you need a Dutch developer who likes the idea and develops it just for us people who have a smart meter.
I used your link to implement it, it works, but that is not just a simple calculation of available sensors/variables. You need to create new variables, add automation rules etc. It should be working out of the box. And as I can read on blogs and forums everyone is asking for that feature (also OpenHab users struggling with this, because it is missing there as well). And I think it can be quite easy implemented inside component.
I was referring to the sql server sensor from ViperRNMC (the message you were replying to).
I agree though that current implementation is far from perfect.
I was not able to implement the sql solution, it showed me very huge number (sum of low and normal? :S). When I was trying to query it using sqlite UI, then I got errors in the query: “)t;” in the end of select, “AND state != ‘unknown’” does not works
Its not that easy, i plugged my dsmr in a vera to get values in an macos hass docker. Min max value is possible, but you need the min max of a day not last 24h or something.
Hey guys, there recently was a smart meter installed in my home for electricity (Iskra SMR 5.0) and gas (FLonidan SMR 5.0) and the mechanic said he linked them together. I bought the usb/p1 cable on sos solutions and configured the dsmr on my hassio. The readings for electricity seem to be working fine, but I get no gas readings. Did anyone encountered this before and knows how to fix this?
Thanks a lot
no, worked right away for me. You should have two gas consumption readings in HA, one is the usage per hour and the other the total gas usage.
@IvaP, @dotms, thanks for sharing your code! It took me some time to figure out that the file needs to be named same as the original one (and not add v2, copy or whatever). Guess I’m still learning
As for the file itself; I had to make some minor changes in order to get this to work. For example replacing the datetime import to support the time functions and remove the self.log as I got a ‘self is not defined’ error (and I’m not interested in this debugging logging).
In addition I removed all the sensors from the array that I’m not using as this is just pollution my device list in the UI.
What would be nice to add (not sure yet how to realize though):
Example:
Assume we get 1 reading per second and we update HASS every 10 seconds as result of the change made earlier. I believe the following is happening.
Data received (current power consumption): 0.410, 0.395, 0.258. 0.560, 1.936, 2.250, 2.168, 1.980, 2.368, 2.201. Data reported to HASS: 2.201 (as this is the 10 second interval)
What I would like to do instead is sum all values and report the average instead which is 1.731 in this case. I’m not a programmer but I believe there should be some way of storing the values in, for example, an array and calculate the average based on the number or items in the array (e.g. to coop with various timeframes).
What do you guys think?
I’m not into the code of HASS lately (in fact I’m not using HASS any more) but the approach of storing the intermediate values in an array seems fine.
For each iteration in your loop check the item count in the array. Once it hits the required number of items calculate the average and send it to HASS.
Just be sure to define that array outside of the loop (to prevent it from being re-initialized every reading and thus never hitting your required number of readings) and to clear its contents after you have calculated the average (to prevent it from getting too big).
The approach is clear; I just don’t understand the dsmr.py code well enough to figure out how to retrieve value for ‘obis_ref.CURRENT_ELECTRICITY_USAGE’ and store this in an array before averaging out and sending to hass.
Apologies for the delay, but better late than never
I personally don’t use my dsmr_custom.py anymore. I use a dedicated Raspberry Pi 3 with DSMR-reader (https://dsmr-reader.readthedocs.io/nl/latest/screenshots.html). DSMR-reader is publishing my stats via MQTT to Home Assistant. Some advantages are very nicely displayed stats inside DSMR-reader and much less load on my HASS.io Raspberry Pi.
I attached my (old) dsmr_custom.py to this post as a .XML-file because file upload restrictions. Just rename the .XML to .py.
dsmr_custom.xml (11.4 KB)
hmm love the looks of the dsmr reader! as I also struggle with high loads for HA I will look into this for sure! Perhaps use it with the new utility meter. As I already have a spare RPi lying around this will be my next project. I might look into doing something similar with my zwave power sensors that record power usage etc as well. As I have quite a few they may also overflow HA with useless info.