Giter Club home page Giter Club logo

smarty-reader's People

Contributors

sgrimee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

smarty-reader's Issues

Compilation Error

Hi,

I receive the following compilation error :

src\smartyreader.cpp: In function 'void onMqttConnect(bool)':
src\smartyreader.cpp:87:31: error: 'start_publishing_dsmr_units' was not declared in this scope
start_publishing_dsmr_units();
^
src\smartyreader.cpp: In function 'void setup()':
src\smartyreader.cpp:149:51: error: 'read_smarty_data' was not declared in this scope
smartyDataReadTimer.attach(READ_SMARTY_EVERY_S, read_smarty_data);
^
*** [.pio\build\d1_mini_pro\src\smartyreader.cpp.o] Error 1

Can you help me please ?

Thanks
Best regards,
Sascha Busser

platformio error

Hi,
does anybody may give me hint how to fix this error in platformio ?
It's running on a Mac M1, all the latest software versions, every other project compiles well (own and clones from github).
Thanks.
BT.

Executing task: platformio run <

Processing d1_mini_pro (platform: espressif8266; board: d1_mini_pro; framework: arduino)

Error: Traceback (most recent call last):
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/main.py", line 102, in main
cli() # pylint: disable=no-value-for-parameter
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/cli.py", line 71, in invoke
return super().invoke(ctx)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/run/cli.py", line 142, in cli
process_env(
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/run/cli.py", line 197, in process_env
result = {"env": name, "duration": time(), "succeeded": ep.process()}
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/run/processor.py", line 83, in process
install_project_env_dependencies(
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/package/commands/install.py", line 132, in install_project_env_dependencies
_install_project_env_libraries(project_env, options),
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/package/commands/install.py", line 225, in _install_project_env_libraries
spec = PackageSpec(library)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/package/meta.py", line 143, in init
self._parse(self.raw)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/package/meta.py", line 250, in _parse
raw = parser(raw)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/package/meta.py", line 275, in _parse_requirements
self.requirements = tokens[1].strip()
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/platformio/package/meta.py", line 190, in requirements
else semantic_version.SimpleSpec(str(value))
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/semantic_version/base.py", line 647, in init
self.clause = self._parse_to_clause(expression)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/semantic_version/base.py", line 1043, in _parse_to_clause
return cls.Parser.parse(expression)
File "/Users/bt/.platformio/penv/lib/python3.9/site-packages/semantic_version/base.py", line 1063, in parse
raise ValueError("Invalid simple block %r" % block)
ValueError: Invalid simple block '7f1ba48'

============================================================

An unexpected error occurred. Further steps:

============================================================

The terminal process "platformio 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

No value after "electricity_switch_position"

Hello,

I got a module from Weigu.lu an I compiled your firmware for the D1 Mini Pro.

I works well with mosquitto and rednode on a raspi but I have a little issue.

I can't get the Smarty P1 values after the "electricity_switch_position" and I have no idea of where come the issue... :/

lamsmarty/p1_version/value 42
lamsmarty/timestamp/value 200321134135W
lamsmarty/equipment_id/value SAG10307XXXXXX
lamsmarty/energy_delivered_tariff1/value 015639.584
lamsmarty/energy_returned_tariff1/value 000000.001
lamsmarty/reactive_energy_delivered_tariff1/value 000394.258
lamsmarty/reactive_energy_returned_tariff1/value 002155.752
lamsmarty/power_delivered/value 00.646
lamsmarty/power_returned/value 00.000
lamsmarty/reactive_power_delivered/value 00.000
lamsmarty/reactive_power_returned/value 00.000
lamsmarty/electricity_threshold/value 27.600
lamsmarty/electricity_switch_position/value 1
lamsmarty/electricity_failures/value (null)
lamsmarty/electricity_sags_l1/value (null)
lamsmarty/electricity_sags_l2/value (null)
lamsmarty/electricity_sags_l3/value (null)
lamsmarty/electricity_swells_l1/value (null)
lamsmarty/electricity_swells_l2/value (null)
lamsmarty/electricity_swells_l3/value (null)
lamsmarty/message_short/value (null)
lamsmarty/message2_long/value (null)
lamsmarty/message3_long/value (null)
lamsmarty/message4_long/value (null)
lamsmarty/message5_long/value (null)
lamsmarty/current_l1/value (null)
lamsmarty/current_l2/value (null)
lamsmarty/current_l3/value (null)
lamsmarty/gas_index/value (null)

Do you have any idea?

Many thanks for your work, it's really great!
Rgds,

Julien

Workaround for random no received data

Hi,

If you face like me some issue for no data received from the Smarty, this is a workaround that may help.
Disclamer: It's my 1st experience in ESP, C++, MQTT, Home Assistant, and many other stuff... so please be kind ^^

Since the firmware upgrade of my Smarty (to get 3 phases values), Sam did a great work to adapt the firmware.

Since this Smarty upgrade, I got random no value received from couple of minutes to days on my MQTT broker.
Almost of the time, I got to unplug/plug the Smarty module board from the Smarty counter to get it working back.

I spent quite a lot of time to understand what was happening but I didn't get the exact reason... (network, power, esp issue).
At the end, the debug was still showing me "no data received" and restart after 10 tries as set in the code didn't unfortunately help.
So I focus on a workaround and I found one that works! :D

The idea was to use the deepSleep mode feature of the D1 Mini Pro and it makes a "real" hard reset on wake.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Carefull, the deepSleep mode required to connect D0(GPIO16) <>RST on the D1 Mini Pro. But once connected, you can't flash anymore. I highly recommand to use a jumper.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1st, I updated the firmware of Sam to get mqtt received features that was not required until now in smartyreader.ino and subscribe to a topic called "smarty/#". My published topic is still set to "lamsmarty/#"

void onMqttConnect(bool sessionPresent) {
  DEBUG_PRINTLN("Connected to MQTT.");
  DEBUG_PRINT("Session present: ");
  DEBUG_PRINTLN(sessionPresent);

  uint16_t packetIdSub = mqttClient.subscribe("smarty/#", 0);
  Serial.print("Subscribing at QoS 2, packetId: ");
  Serial.println(packetIdSub);
 
  start_publishing_dsmr_units();
}

and

void onMqttSubscribe(uint16_t packetId, uint8_t qos) {
  DEBUG_PRINTLN("Subscribe acknowledged.");
  DEBUG_PRINT("  packetId: ");
  DEBUG_PRINTLN(packetId);
  DEBUG_PRINT("  qos: ");
  DEBUG_PRINTLN(qos);
}

void onMqttUnsubscribe(uint16_t packetId) {
  DEBUG_PRINTLN("Unsubscribe acknowledged.");
  DEBUG_PRINT("  packetId: ");
  DEBUG_PRINTLN(packetId);
}

void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
  DEBUG_PRINTLN("Publish received.");
  DEBUG_PRINT("  topic: ");
  DEBUG_PRINTLN(topic);
  DEBUG_PRINT("  qos: ");
  DEBUG_PRINTLN(properties.qos);
  DEBUG_PRINT("  dup: ");
  DEBUG_PRINTLN(properties.dup);
  DEBUG_PRINT("  retain: ");
  DEBUG_PRINTLN(properties.retain);
  DEBUG_PRINT("  len: ");
  DEBUG_PRINTLN(len);
  DEBUG_PRINT("  index: ");
  DEBUG_PRINTLN(index);
  DEBUG_PRINT("  total: ");
  DEBUG_PRINTLN(total);

Then I used this action for the D1 Mini Pro to enter in deepSleep after 30s when the topic "smarty/deepsleep" is sent to my MQTT broker

  //Deepsleep for 30s on received MQTT message from HomeAssistant MQTT broker
  // Check if the MQTT message was received on topic smarty/deepsleep
  if (strcmp(topic,"smarty/deepsleep") == 0) {
  DEBUG_PRINTLN("Deepsleep for 30s requested");
  ESP.deepSleep(30e6);
  }

Then I set a kind of watchdog sensor in Home Assistant (that I use now instead of nodered) where smarty_check" is a history graph and smarty_binary a status (false/true).

        smarty_check:
          friendly_name: "Smarty check"
          unit_of_measurement: "Seconds"
          value_template: "{{ (now() - states.sensor.power_delivered.last_updated ).total_seconds() }}"

        smarty_binary:
          friendly_name: "Smarty binary"
          value_template: "{{ (now() - states.sensor.power_delivered.last_updated ).total_seconds() > 30 }}"

Then, still form Home Assistant, I created this automation to send the "magic" topic to deepsleep/hardreset the D1 and to get a notification on my smartphone if the Smarty/D1 Mini Pro do not provide data after 2 minutes.

- id: '1618164423737'
  alias: Notify and restart Smarty
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.smarty_binary
    from: 'False'
    to: 'True'
    for: 00:02:00
  condition: []
  action:
  - device_id: e21cdac2219581b0571fc0be730ec685
    domain: mobile_app
    type: notify
    title: 'Smarty unavailable for 2 min, deepSleep has been activated '
    message: The smarty restarted
  - service: mqtt.publish
    data:
      topic: 'smarty/deepsleep'
  mode: single

That's it and I hope it could help of someone that is facing the same issue.

Also the deepsleep mode automation could be directly integrated in the firmware I suppose. Then no need specific yaml code in Home Assistant. I will try to do that later, it should be quite easy now.

Don't hesitate to ask for more info.

Thanks for reading.
And also to Sam for his continous support to get this workaround alive!

Cheers!

Julien

Does it work with Iskra AM550?

Hello,
is this Project meant to work also with the ISKRA AM550-TD2.11 SmartMeter (i live in Austria).

I got from my supplyer the 16 byte encryption key but it seams not working.
I got every second a stream out of my meter. So the hardware is working.

Here is a sample:
7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 13 FC DD 72 BB 6A 7D 54 3B 82 A5 55 41 EB 82 0A 8D F2 B9 BB 24 28 21 E3 50 98 EF 79 CE DB F3 4E 67 02 AC 3B 84 FB 85 BF 7B F5 E8 B6 85 BF 73 DA AC D1 4F A3 8F E0 7C 0D 35 9E B6 B6 DB E7 63 DD 64 AD 66 3B 00 F5 2B 48 2E 26 14 E4 1C 2A 7D 7B 14 85 33 18 CB 5C 33 3D 2E 27 D8 A9 53 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 14 F8 02 C7 FE 65 57 92 FE 65 22 9C 27 77 9D 7F 25 70 6E F9 C0 A8 3B 8E 18 88 F5 0E 6A E4 98 47 38 1A ED 85 72 DB 55 BB 13 7C D4 27 79 7F E8 56 7E 17 B0 30 86 F7 7C AD EF 57 5A 97 44 41 67 B3 33 31 24 8C 62 8D 8D 55 C5 D2 A3 9B C5 B2 34 9C C8 F8 58 46 3B CC 93 DB 68 81 56 49 1A 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 15 6D E2 F6 26 7A 9E 20 A9 FC 89 92 99 BC 19 80 57 7D E6 E9 78 69 CC 07 A7 0E 2B FA BE F4 5A F1 13 1B D1 9C 2E 70 15 8F F1 28 39 1F 9A DF F6 3A 5B F4 DA A7 1B 43 E0 B4 97 84 E7 D8 0F DF E1 26 89 47 87 3E 06 1A 6C C9 1C E7 5F 15 ED 06 AF 53 69 59 97 91 95 86 05 66 9F 4F D4 FE 08 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 16 67 21 22 3D 73 0B B4 86 B1 70 7D 30 54 A4 00 C9 59 5D 30 64 DC D8 A2 70 6D 5B 08 A5 99 45 54 B6 B0 02 E8 E7 D8 D7 C6 6D 8D AA C0 A4 97 3C EA 4F 16 FA 62 ED DF 15 E0 6F D5 D6 81 71 C0 3E FF A3 B6 37 38 3B 5D 56 FF AD B9 AF D0 35 84 CB 8D A3 DD 99 FD 44 A2 54 EC 5C E1 9D D8 4C 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 17 32 21 5C 8A 9B 21 F4 9D 7F 3C 86 6B AD BC DF E6 01 CD 5F 81 AB F5 0B 90 B6 9D 03 FE 85 7B F1 EB F2 D2 16 44 58 F8 D0 33 ED 30 35 FA 80 B1 6D 55 AF D0 68 64 49 2B EC B3 5C 9A 1B 08 B4 C4 81 1A F8 F5 19 E4 FE F2 0B B5 38 D6 8C 18 7F E4 DD B5 AF C1 E6 4F FE 1E 20 98 54 28 AF FD 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 18 82 E5 92 2B 75 49 8C D5 4B 63 F5 2E D9 FD 11 79 CB 8C AC 6D E0 E3 19 10 49 2B 81 B9 82 16 EC 42 F2 B8 DC 6F 6C 1B 19 7B 6D 65 9C 9D 5E FF 45 BB 50 F9 FB 8C 28 A2 02 53 87 0C 27 0D 4D 02 C0 3B 4B 21 87 E6 43 90 19 D1 23 49 4B 2B 8E 9F 25 DA A9 F4 42 78 12 3E E4 5C 6C 60 73 8D 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 19 01 87 57 19 58 A2 3D 2A 69 72 C1 C0 E6 DF 33 D7 1E D2 F2 DA 11 47 48 8A DD 1C 7C 3B A0 F5 8F 11 3B CC 12 62 33 5D EC 55 C5 19 F7 2D 80 E5 83 1E 37 8D EB 3D 79 49 3E EA F6 F4 CC 2F 47 2F 75 E9 33 64 F2 25 20 DF 50 64 BA 93 64 83 2F DB AC AC 76 AC 47 D4 E7 77 CF 75 F6 1D B7 55 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 1A 70 DF A6 9E 14 E4 D3 35 5D 80 90 76 25 9A F7 12 70 00 F4 4A 4D D7 D8 20 7B 5F F0 76 08 8A FE 99 1D 77 46 2E 78 59 7C 35 C2 17 19 FA 8F 7E 0B 2C 62 2A 94 EE 4C AF E2 A8 16 0B 4D D2 92 50 8A B1 47 6D 3A 10 BD 53 3A D4 A3 61 18 8A 4B 41 BE 5C 6A 7B 8A 88 A1 C0 48 28 75 42 38 C5 7E 7E A0 77 CF 02 23 13 BB 45 E6 E7 00 DB 08 49 53 4B 69 74 52 E7 E3 5F 20 00 00 05 1B FA 19 42 56 2A B1 EF 02 EB 0D 62 2D 42 0E 3E 6C BE 39 48 C2 F5 14 2B F9 FF 8F A2 EB DF C0 35 38 AE 9B 80 3F 8C 24 21 54 1A 1A 78 D4 53 A2 E1 8F 29 F2 EB 05 D5 46 10 42 16 03 93 C6 42 03 6F 4E 52 EC 06 C5 69 86 CF EA 36 27 DD 86 C9 6E 30 23 91 4D 8B AC 16 14 32 84 2A 3C 79 C6 7E

The whole thing starts with an 0x7E and what i can reat out of the description, it should start with an 0xDB - it this right?

I got the info from my supplier:
Protocol: DLMS
Interval: 1 second
Security: Cosem Suite 0; High Level Security (HLS); AES128

So is there anything that i can try to get it working?

Thanks for your time!

BR ipirk

Handle unencrypted data also?

Is it easy/possible to enable this code to also handle unencrypted data from smart meters?
In Sweden were I am form power companies has decided that data on P1 port should be in plain ASCII.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.