Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSMR - Ability to use multiple keys and uart assigned sensors #2062

Closed
SecSelS opened this issue Jan 13, 2023 · 18 comments · Fixed by esphome/esphome#4299
Closed

DSMR - Ability to use multiple keys and uart assigned sensors #2062

SecSelS opened this issue Jan 13, 2023 · 18 comments · Fixed by esphome/esphome#4299

Comments

@SecSelS
Copy link

SecSelS commented Jan 13, 2023

Describe the problem you have/What new integration you would like

Hi =) We just opensourced this board https://github.com/SecSelS/SecSi-Energy-Monitor and it has 2x p1/rj12 interfaces for p1 energymeters. The problem is that the telegrams in luxemburg (and possible other countries) are encrypted and you need a DSMR-Key. The problem is, that for every Meter you need a seperate key. As our device has two ports, you can read two meters simultaniously (which is important when you have solar cells, as energy-companies place always two meters in this case). As far as we have seen/tested, you can just use one DSMR-Key per uart correct? Also we're not sure if you can assign the sensors to one uart. So we found it was possible to configure multiple uart (as we're using both with a jumper for the p1 ports -> esphome/issues#521) but no possibility to assign multiple DSMR-Keys for seperate uarts. If our assumptions are correct, we wanted to request to implement the feature of seperate DSMR-Keys per uart, and assign the sensors to seperate uarts. If it is just a config-issue, we would be very glad if you point us to the correct yaml syntax.

Please describe your use case for this integration and alternatives you've tried:

The use case would be for households that use our board and have two meters installed. (See above)

Additional context

The yaml we use at the moment, the complete Hardware-Docs and design-files are in our github. If you need any more information I would be very happy to assist =)

@SecSelS SecSelS changed the title DSMR - Ability to use two keys and uart assigned sensors DSMR - Ability to use multiple keys and uart assigned sensors Jan 13, 2023
@nagyrobi
Copy link
Member

All I see on https://shop.secsels.com is a Terms and Conditions page. Product is missing.

@SecSelS
Copy link
Author

SecSelS commented Jan 13, 2023

yes because it comes online on the course of next week...we have to translate the AGB to french because we're in luxemburg, and we work very hard this weekend to make it happen as soon as possible =)...as soon as it is online i'll tell here =)

@nagyrobi
Copy link
Member

What's the expected price, with shipping to Europe?
(I have 2 meters aswell)

@SecSelS
Copy link
Author

SecSelS commented Jan 13, 2023

we'll calculate all this in the weekend, but shipping to europe will be available =). we also working on opensource enclosure which will also be sold as well, but not yet on the weekend...

@ssieb
Copy link
Member

ssieb commented Jan 14, 2023

I think if you had uncommented the second dsmr, you would have gotten a compile error that would have guided you to the solution.

sensor:
  - platform: dsmr
    dsmr_id: dsmr_p1_1
    ...

@ssieb ssieb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2023
@SecSelS
Copy link
Author

SecSelS commented Jan 14, 2023

Yes that's true for the sensors, but not for the key-section...I was not able to test it on a real meter as in Luxembourg all meters are encrypted...so to connect it to a second meter I need to define a second DSMR key...so it's more about this section:

dsmr:
# here the dsmr for the first p1 port is defined
  id: dsmr_p1_1
  decryption_key: !secret dsmr_key_p1_1
  max_telegram_length: 1700
# here the dsmr for the second p1 port is defined
# use only if you have a second meter connected,
# and the pins are configured for uart-communication
#  - id: dsmr_p1_2
#    decryption_key: !secret dsmr_key_p1_2
#    max_telegram_length: 1700

I tried to define a list here (like in the comment and like with uart) but it gives a compile error when I add a second key...

@ssieb
Copy link
Member

ssieb commented Jan 14, 2023

Show the config with that part uncommented, because what you have there would be invalid yaml if you uncomment that.

@SecSelS
Copy link
Author

SecSelS commented Jan 14, 2023

I tried it like in the uart section as list:

uart:
  - rx_pin:
      number: GPIO16
    baud_rate: 115200
    rx_buffer_size: 1700
    id: uart_p1_1
# Here the second P1 UART is defined (just uncomment if you use second p1)
  - rx_pin:
      number: GPIO3
    baud_rate: 115200
    rx_buffer_size: 1700
    id: uart_p1_2

# here the dsmr for the first p1 port is defined
dsmr:
  - uart_id: uart_p1_1
    id: dsmr_p1_1_key
    decryption_key: !secret dsmr_key_p1_1
    max_telegram_length: 1700
# here the dsmr for the second p1 port is defined
# use only if you have a second meter connected,
# and the pins are configured for uart-communication
  - uart_id: uart_p1_2
    id: dsmr_p1_2_key
    decryption_key: !secret dsmr_key_p1_1
    max_telegram_length: 1700
 
sensor:
  - platform: dsmr
    dsmr_id: dsmr_p1_1
    energy_delivered_lux:
      name: "Energy Consumed"
      state_class: total_increasing

But when I try to compile I get: "Failed config, expected a dictionary" for the DSMR secretion...

@ssieb
Copy link
Member

ssieb commented Jan 14, 2023

Ok, now that's the real problem. Try adding this to your config and see if both will work:

external_components:
  - source:
      type: git
      url: https://github.com/ssieb/esphome
      ref: dsmr
    components: [ dsmr ]

@ssieb ssieb reopened this Jan 14, 2023
@SecSelS
Copy link
Author

SecSelS commented Jan 14, 2023

This compiles perfectly and reading looks good (couldn't test with a second meter here, but should be ok) =) great great thanks! =) will this be merged? Or do I always need the external component?

@SecSelS
Copy link
Author

SecSelS commented Jan 14, 2023

Here is my working Test-configuration for reference...I striped away the comments, and defined just two dsmr-sensors to make it better readable. Thanks @ssieb ! Wouldn`t work without the external component part! Second port on the board also confirmed working! I was not able to test with two meters simultaneously, but it seems okay.

substitutions:
  device_name: secsi-energy-monitor
  device_description: Energy meter by secsels.com
  ap_fallback_password: secsi-device
     
esphome:
  name: ${device_name}
  name_add_mac_suffix: false
  comment: "${device_description}"

esp32:
  board: esp32dev
  framework:
    type: arduino

wifi:
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password

  ap:
    ssid: ${device_name}
    password: ${ap_fallback_password}
    ap_timeout: 15s
 
captive_portal:
 
logger:
  baud_rate: 0

api:

ota:
  safe_mode: true

web_server:
  port: 80

uart:
  - rx_pin:
      number: GPIO16
    baud_rate: 115200
    rx_buffer_size: 1700
    id: uart_p1_1

  - rx_pin:
      number: GPIO3
    baud_rate: 115200
    rx_buffer_size: 1700
    id: uart_p1_2

dsmr:
  - uart_id: uart_p1_1
    id: dsmr_p1_1_key
    decryption_key: !secret dsmr_key_p1_1
    max_telegram_length: 1700

  - uart_id: uart_p1_2
    id: dsmr_p1_2_key
    decryption_key: !secret dsmr_key_p1_1
    max_telegram_length: 1700
 
sensor:
  - platform: dsmr
    dsmr_id: dsmr_p1_1_key
    energy_delivered_lux:
      name: "Energy Consumed"
      state_class: total_increasing

  - platform: dsmr
    dsmr_id: dsmr_p1_2_key
    energy_delivered_lux:
      name: "Energy Consumed2"
      state_class: total_increasing

external_components:
  - source:
      type: git
      url: https://github.com/ssieb/esphome
      ref: dsmr
    components: [ dsmr ]

@ssieb
Copy link
Member

ssieb commented Jan 14, 2023

It would be good if you could test it with two meters at the same time. I didn't look too closely, so I don't know if it was intentionally only for one, but probably not. If you can't test it, we'll just merge it anyway in a few days.

@SecSelS
Copy link
Author

SecSelS commented Jan 15, 2023

Okay... I'll try to find someone here with two meters. The way I'll tested was: I made both definitions like above, and then I simply switched ports. Both decrypted well,.and the values were displayed under the right sensor. Great great thanks @ssieb !

@nagyrobi
Copy link
Member

...run a long RJ11 cable to your neighbor...

@SecSelS
Copy link
Author

SecSelS commented Jan 15, 2023

🤣
We use rj12 to get power too ;-)

jesserockz pushed a commit to esphome/esphome that referenced this issue Jan 16, 2023
Co-authored-by: Samuel Sieb <samuel@sieb.net>
fixes esphome/feature-requests#2062
@SecSelS
Copy link
Author

SecSelS commented Jan 16, 2023

Great great thanks for merging :-) I was not yet able to test with two meters at the same time, but I configured "as there were" two at the same time, and just switched ports (which works perfectly :-)). So I guess its perfect :-).

@nagyrobi and everyone interested in a board please contact us directly as I don't want to spam here: https://secsels.com/kontakt/

@SecSelS
Copy link
Author

SecSelS commented Jan 23, 2023

Confirmed working on two meters at the same time =) (I tried it with DSMR_Identification Sensor, and both show a reading)

@SecSelS
Copy link
Author

SecSelS commented Apr 6, 2023

All I see on https://shop.secsels.com is a Terms and Conditions page. Product is missing.

Just to notify @nagyrobi we're in stock =)

@github-actions github-actions bot locked and limited conversation to collaborators Aug 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants