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

[NASA] Power Consumption #6

Closed
bzumik1 opened this issue Aug 24, 2023 · 63 comments · Fixed by #208
Closed

[NASA] Power Consumption #6

bzumik1 opened this issue Aug 24, 2023 · 63 comments · Fixed by #208

Comments

@bzumik1
Copy link
Contributor

bzumik1 commented Aug 24, 2023

Will it be possible to add power consumption for NASA devices? Also is there some way how to support you? You are doing great job!

@lanwin
Copy link
Collaborator

lanwin commented Aug 25, 2023

Not sure. I think I have seen some power values. So when they exists it should be simple to add them.

Give me some time. My desk is currently pretty full.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Aug 25, 2023

Fully understand that, I really love this project. If there would be anything I could help with please let me know.

@lanwin
Copy link
Collaborator

lanwin commented Aug 25, 2023

Yes you can. You can help tests this and also help improve the documentation. I terms like. Did its understandable, is there anything missing. Adding working devices...etc.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Aug 25, 2023

Ok, as soon as I will receive the necessary hardware I will start with testing.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 2, 2023

Hi, so you are able to see the power consumption? That is great! I should have my HW today, looking forward to test it as well 🙂

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 2, 2023

Ok, I am little bit confused because you wrote

I installed it and it works on the model: AC052RNMDKG/AC0RXADKG.

To issue Power Consumption NASA 🙂.

BTW how do you read it using Modbus? You have convertor from NASA to Modbus?

@bzumik1 bzumik1 changed the title Power Consumption NASA [NASA] Power Consumption Oct 3, 2023
@lanwin
Copy link
Collaborator

lanwin commented Oct 3, 2023

Hu it seems he deleted his posts.

A friend of mine uses the WIFI Kit from Samsung and there is a power consumption chart available. It must be possible the read that data. But I did not find the right message for that yet.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 3, 2023

I have WiFi Kit also available, right now I have replaced it with ESPHome with your code, but I could connect both if that would help somehow ...

@lanwin
Copy link
Collaborator

lanwin commented Oct 3, 2023

Yes that would be a good idea. I did not know If the wifikit simply receives power messages or if it ask for it when the chart is accessed in the app.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 3, 2023

Ok, I will try to connect it today or tomorrow. I have quite complicated access to communication bus so it will take me some time 😄

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 3, 2023

Hi @lanwin, I connected the WiFi Kit back again and checked the power consumption in App, I did so at 16:40:00, here are the logs:

esp-samsung-ac-power-consumption.log

hopefully it will be helpful.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 4, 2023

Hi @lanwin did you have time to check the the logs? Was there any useful information? If not let me know if I should test something else.

@lanwin
Copy link
Collaborator

lanwin commented Oct 5, 2023

@bzumik1 currently the log contains only stuff I didnt filter out. There are a lot more messages you can not see. I will add an config property to enable logging soon.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 5, 2023

Oh I see, let me know when the more detailed logging would be available and I will record the logs once again.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 8, 2023

Hi @lanwin, how does it look with the advanced logging?

@sredfern
Copy link

sredfern commented Oct 16, 2023

Hey @bzumik1 - I'm actually planning on picking this up. Had a NASA 3 head unit installed in my house last week and stumbled across this project. I have a seperate current clamp measuring the AC codenser for real power usage and have found that the Samsung app is under reporting usage by around 60%. 🤞 for PR's coming in the next few weeks.

Happy to help this side of the project as I'm pretty excited about exploring this.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 16, 2023

That sounds great. Thank you @sredfern

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 23, 2023

Hi @sredfern, how do you progress? Do you need some help with testing?

@sredfern
Copy link

F26B89FA-CACC-4593-ACA7-6604D4491A5E

Still working on getting my hardware up. Have built a seperate rs485 listener with a PiZeroW that I want to connect at the same time so I can dump the data into a database for analysis.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Oct 25, 2023

It looks awesome!

@bzumik1
Copy link
Contributor Author

bzumik1 commented Nov 1, 2023

Hi @sredfern were you able to read the data and load them to DB?

@sredfern
Copy link

sredfern commented Nov 2, 2023

Hey @bzumik1 This is a hobby project for me and I've got a whole life outside of this (kids, job, house, life). It's pretty demotivating for someone to just endlessly comment on stuff asking to follow up. If you're so excited about working on it (and have the time to learn) can I suggest you attempt to fix it? I won't speak for the creator of this project but trying to solve the problem yourself is the greatest contribution you can make to this project, not following up every week.

@bzumik1
Copy link
Contributor Author

bzumik1 commented Nov 2, 2023

Hi @sredfern I understand your perspective and apologize if I've bothered you. Unfortunately, due to my limited knowledge, I can't assist with the code, but I've tried to improve the documentation and keep the developed features up to date. My interest was based on a positive approach and supporting the project, not on demotivation. Thank you for your work on the project, and I want to express my gratitude for what you've accomplished so far.

@sredfern
Copy link

sredfern commented Nov 4, 2023

It's really great that you're excited but the way to keep other people excited isn't to bug them about getting something done. It's not hard to work out how it all works. Reminding people who can do this stuff how little time they have is a sure fire way of people losing interest.

I managed to not need my raspberry pi method. Have managed to used the UARTDebug to spam the log with all the data from the RS485 bus.

logger:
  tx_buffer_size: 1024

uart:
  tx_pin: GPIO26
  rx_pin: GPIO18
  rx_buffer_size: 1024
  baud_rate: 9600
  parity: EVEN
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_hex(direction, bytes, '.');
 

@sredfern
Copy link

sredfern commented Nov 6, 2023

OK, managed to get all of the commands into my local Loki instance. Going to start digging around and seeing what I can make now.

If interested, make sure your syslog supports udp packets :

external_components:
  - source: github://TheStaticTurtle/esphome_syslog
    components: [syslog]
  - source: github://lanwin/esphome_samsung_ac@main
    components: [samsung_ac]

syslog:
  ip_address: "XX.XX.XX.XX"
  port: 514
  min_level: VERY_VERBOSE
  enable_logger: true
Screenshot 2023-11-06 at 11 56 22 pm

@sredfern
Copy link

sredfern commented Nov 12, 2023

Had some better success understanding the protocol using this uart config if others are keen.

uart:
  tx_pin: GPIO26
  rx_pin: GPIO18
  rx_buffer_size: 1024
  baud_rate: 9600
  parity: EVEN
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: [0x34]
    sequence:
      - lambda: UARTDebug::log_hex(direction, bytes, ' ');

It gives you a much cleaner output to try and understand the protocol.
Screenshot 2023-11-12 at 10 46 55 pm

I've included some of my basic progress below:

FB FB FB FB FB 32 00 11 62 00 67 B0 FF FF B0 00 FF C0 14, 16,13 62 01
unknown Command Start Length (hex) Destination Source In almost all lines. May need to think about removing some of these. Something. Mostly always 14 This is the length

@bzumik1
Copy link
Contributor Author

bzumik1 commented Nov 12, 2023

Thanks for updates!

@bzumik1
Copy link
Contributor Author

bzumik1 commented Nov 12, 2023

@sredfern may I ask what program you are using to analyse those logs, it seems quite handy.

@lanwin
Copy link
Collaborator

lanwin commented Nov 13, 2023

@sredfern thank you for your effort!

But I am not sure what you do there. If you want to know how to decode the protocol you simply have to look at https://github.com/lanwin/esphome_samsung_ac/blob/main/components/samsung_ac/nasa.cpp . There is everything you need to know on how to decode the protocol.

The point is that the NASA protocol is pretty generic. Its not like the non NASA protocol witch is really specific. The NASA protocol is simply like a way to send generic variables as messages out over the wire.

The difficult part is to find witch variable does what. If I wouldn't be able to decompile the source of SNET, it would have take much much longer to come up with this project. But even SNET does not references all variables I receive.

@sredfern
Copy link

sredfern commented Nov 15, 2023

Hey Steve,

Thanks for your help. I've tried the following:

  1. Clean rebuild
  2. I had originally used the mqtt HA auto configuration but tried using a manual mqtt (with username and password) with the same error very early in the compile step:

I've extracted out the verbose compile step:

DEBUG Running to_code in esphome.components.mqtt (num 10)
DEBUG Adding: // mqtt:
DEBUG Adding: //   broker: 192.168.*****
//   username: samsung_ac
//   password: ******
//   discovery: false
//   id: mqtt_mqttclientcomponent
//   port: 1883
//   discovery_retain: true
//   discovery_prefix: homeassistant
//   discovery_unique_id_generator: legacy
//   discovery_object_id_generator: none
//   use_abbreviations: true
//   topic_prefix: samsung-ac-control
//   keepalive: 15s
//   reboot_timeout: 15min
//   birth_message:
//     topic: samsung-ac-control/status
//     payload: online
//     qos: 0
//     retain: true
//   will_message:
//     topic: samsung-ac-control/status
//     payload: offline
//     qos: 0
//     retain: true
//   shutdown_message:
//     topic: samsung-ac-control/status
//     payload: offline
//     qos: 0
//     retain: true
//   log_topic:
//     topic: samsung-ac-control/debug
//     qos: 0
//     retain: true
DEBUG Adding global: mqtt::MQTTClientComponent *mqtt_mqttclientcomponent;
DEBUG Adding: mqtt_mqttclientcomponent = new mqtt::MQTTClientComponent();
DEBUG Registered variable mqtt_mqttclientcomponent of type mqtt::MQTTClientComponent
DEBUG Adding: mqtt_mqttclientcomponent->set_component_source("mqtt");
DEBUG Adding: App.register_component(mqtt_mqttclientcomponent);
DEBUG Adding library: ottowinter/[email protected]
DEBUG Adding define: <esphome.core.Define object at 0x10b141610>
DEBUG Adding global: using namespace mqtt;
DEBUG Adding: mqtt_mqttclientcomponent->set_broker_address("192.168.*****");
DEBUG Adding: mqtt_mqttclientcomponent->set_broker_port(1883);
DEBUG Adding: mqtt_mqttclientcomponent->set_username("samsung_ac");
DEBUG Adding: mqtt_mqttclientcomponent->set_password("******");
DEBUG Adding: mqtt_mqttclientcomponent->disable_discovery();
DEBUG Adding: mqtt_mqttclientcomponent->set_topic_prefix("samsung-ac-control");
DEBUG Adding define: <esphome.core.Define object at 0x10b141a50>
DEBUG Adding: mqtt_mqttclientcomponent->set_birth_message(mqtt::MQTTMessage{
    .topic = "samsung-ac-control/status",
    .payload = "online",
    .qos = 0,
    .retain = true,
});
DEBUG Adding: mqtt_mqttclientcomponent->set_last_will(mqtt::MQTTMessage{
    .topic = "samsung-ac-control/status",
    .payload = "offline",
    .qos = 0,
    .retain = true,
});
DEBUG Adding: mqtt_mqttclientcomponent->set_shutdown_message(mqtt::MQTTMessage{
    .topic = "samsung-ac-control/status",
    .payload = "offline",
    .qos = 0,
    .retain = true,
});
DEBUG Adding: mqtt_mqttclientcomponent->set_log_message_template(mqtt::MQTTMessage{
    .topic = "samsung-ac-control/debug",
    .payload = "",
    .qos = 0,
    .retain = true,
});
DEBUG Adding: mqtt_mqttclientcomponent->set_keep_alive(15);
DEBUG Adding: mqtt_mqttclientcomponent->set_reboot_timeout(900000);
DEBUG  -> finished

....

DEBUG Adding global: samsung_ac::Samsung_AC *samsung_ac_samsung_ac;
DEBUG Adding: samsung_ac_samsung_ac = new samsung_ac::Samsung_AC();
DEBUG Registered variable samsung_ac_samsung_ac of type samsung_ac::Samsung_AC
DEBUG Adding global: samsung_ac::Samsung_AC_Device *samsung_ac_samsung_ac_device;
DEBUG Adding: samsung_ac_samsung_ac_device = new samsung_ac::Samsung_AC_Device("20.00.00", samsung_ac_samsung_ac);
DEBUG Registered variable samsung_ac_samsung_ac_device of type samsung_ac::Samsung_AC_Device
DEBUG Adding global: samsung_ac::Samsung_AC_Switch *samsung_ac_samsung_ac_switch;
DEBUG Adding: samsung_ac_samsung_ac_switch = new samsung_ac::Samsung_AC_Switch();
DEBUG Registered variable samsung_ac_samsung_ac_switch of type samsung_ac::Samsung_AC_Switch
DEBUG Adding: App.register_switch(samsung_ac_samsung_ac_switch);
DEBUG Adding: samsung_ac_samsung_ac_switch->set_name("main_bedroom_power");
DEBUG Adding: samsung_ac_samsung_ac_switch->set_disabled_by_default(false);
DEBUG Adding global: mqtt::MQTTSwitchComponent *mqtt_mqttswitchcomponent;
DEBUG Adding: mqtt_mqttswitchcomponent = new mqtt::MQTTSwitchComponent(samsung_ac_samsung_ac_switch);
DEBUG Registered variable mqtt_mqttswitchcomponent of type mqtt::MQTTSwitchComponent
DEBUG Adding: mqtt_mqttswitchcomponent->set_component_source("mqtt");
DEBUG Adding: App.register_component(mqtt_mqttswitchcomponent);
DEBUG Adding: samsung_ac_samsung_ac_switch->set_restore_mode(switch_::SWITCH_RESTORE_DEFAULT_OFF);
DEBUG Adding: samsung_ac_samsung_ac_device->set_power_switch(samsung_ac_samsung_ac_switch);
DEBUG Adding global: sensor::Sensor *sensor_sensor;
DEBUG Adding: sensor_sensor = new sensor::Sensor();
DEBUG Registered variable sensor_sensor of type sensor::Sensor
DEBUG Adding: App.register_sensor(sensor_sensor);
DEBUG Adding: sensor_sensor->set_name("main_bedroom_room_temp");
DEBUG Adding: sensor_sensor->set_disabled_by_default(false);
DEBUG Adding: sensor_sensor->set_device_class("temperature");
DEBUG Adding: sensor_sensor->set_state_class(sensor::STATE_CLASS_MEASUREMENT);
DEBUG Adding: sensor_sensor->set_unit_of_measurement("\302\260C");
DEBUG Adding: sensor_sensor->set_accuracy_decimals(1);
DEBUG Adding: sensor_sensor->set_force_update(false);
DEBUG Adding global: mqtt::MQTTSensorComponent *mqtt_mqttsensorcomponent;
DEBUG Adding: mqtt_mqttsensorcomponent = new mqtt::MQTTSensorComponent(sensor_sensor);
DEBUG Registered variable mqtt_mqttsensorcomponent of type mqtt::MQTTSensorComponent
DEBUG Adding: mqtt_mqttsensorcomponent->set_component_source("mqtt");
DEBUG Adding: App.register_component(mqtt_mqttsensorcomponent);
DEBUG Adding: samsung_ac_samsung_ac_device->set_room_temperature_sensor(sensor_sensor);
DEBUG Adding global: sensor::Sensor *sensor_sensor_2;
DEBUG Adding: sensor_sensor_2 = new sensor::Sensor();
DEBUG Registered variable sensor_sensor_2 of type sensor::Sensor
DEBUG Adding: App.register_sensor(sensor_sensor_2);
DEBUG Adding: sensor_sensor_2->set_name("main_bedroom_room_humidity");
DEBUG Adding: sensor_sensor_2->set_disabled_by_default(false);
DEBUG Adding: sensor_sensor_2->set_device_class("humidity");
DEBUG Adding: sensor_sensor_2->set_state_class(sensor::STATE_CLASS_MEASUREMENT);
DEBUG Adding: sensor_sensor_2->set_unit_of_measurement("%");
DEBUG Adding: sensor_sensor_2->set_accuracy_decimals(0);
DEBUG Adding: sensor_sensor_2->set_force_update(false);
DEBUG Adding global: mqtt::MQTTSensorComponent *mqtt_mqttsensorcomponent_2;
DEBUG Adding: mqtt_mqttsensorcomponent_2 = new mqtt::MQTTSensorComponent(sensor_sensor_2);
DEBUG Registered variable mqtt_mqttsensorcomponent_2 of type mqtt::MQTTSensorComponent
DEBUG Adding: mqtt_mqttsensorcomponent_2->set_component_source("mqtt");
DEBUG Adding: App.register_component(mqtt_mqttsensorcomponent_2);
DEBUG Adding: samsung_ac_samsung_ac_device->set_room_humidity_sensor(sensor_sensor_2);
DEBUG Adding global: samsung_ac::Samsung_AC_Number *samsung_ac_samsung_ac_number;
DEBUG Adding: samsung_ac_samsung_ac_number = new samsung_ac::Samsung_AC_Number();
DEBUG Registered variable samsung_ac_samsung_ac_number of type samsung_ac::Samsung_AC_Number
DEBUG Adding: App.register_number(samsung_ac_samsung_ac_number);
DEBUG Adding: samsung_ac_samsung_ac_number->set_name("main_bedroom_target_temp");
DEBUG Adding: samsung_ac_samsung_ac_number->set_disabled_by_default(false);
DEBUG Adding: samsung_ac_samsung_ac_number->traits.set_min_value(16.0f);
DEBUG Adding: samsung_ac_samsung_ac_number->traits.set_max_value(30.0f);
DEBUG Adding: samsung_ac_samsung_ac_number->traits.set_step(1.0f);
DEBUG Adding: samsung_ac_samsung_ac_number->traits.set_mode(number::NUMBER_MODE_AUTO);
DEBUG Adding: samsung_ac_samsung_ac_number->traits.set_unit_of_measurement("\302\260C");
DEBUG Adding global: mqtt::MQTTNumberComponent *mqtt_mqttnumbercomponent;
DEBUG Adding: mqtt_mqttnumbercomponent = new mqtt::MQTTNumberComponent(samsung_ac_samsung_ac_number);
DEBUG Registered variable mqtt_mqttnumbercomponent of type mqtt::MQTTNumberComponent
DEBUG Adding: mqtt_mqttnumbercomponent->set_component_source("mqtt");
DEBUG Adding: App.register_component(mqtt_mqttnumbercomponent);
DEBUG Adding: samsung_ac_samsung_ac_number->traits.set_device_class("temperature");
DEBUG Adding: samsung_ac_samsung_ac_device->set_target_temperature_number(samsung_ac_samsung_ac_number);
DEBUG Adding global: samsung_ac::Samsung_AC_Mode_Select *samsung_ac_samsung_ac_mode_select;
DEBUG Adding: samsung_ac_samsung_ac_mode_select = new samsung_ac::Samsung_AC_Mode_Select();
DEBUG Registered variable samsung_ac_samsung_ac_mode_select of type samsung_ac::Samsung_AC_Mode_Select
DEBUG Adding: App.register_select(samsung_ac_samsung_ac_mode_select);
DEBUG Adding: samsung_ac_samsung_ac_mode_select->set_name("main_bedroom_mode");
DEBUG Adding: samsung_ac_samsung_ac_mode_select->set_disabled_by_default(false);
DEBUG Adding: samsung_ac_samsung_ac_mode_select->traits.set_options({"Auto", "Cool", "Dry", "Fan", "Heat"});
DEBUG Adding global: mqtt::MQTTSelectComponent *mqtt_mqttselectcomponent;
DEBUG Adding: mqtt_mqttselectcomponent = new mqtt::MQTTSelectComponent(samsung_ac_samsung_ac_mode_select);
DEBUG Registered variable mqtt_mqttselectcomponent of type mqtt::MQTTSelectComponent
DEBUG Adding: mqtt_mqttselectcomponent->set_component_source("mqtt");
DEBUG Adding: App.register_component(mqtt_mqttselectcomponent);
DEBUG Adding: App.register_select(samsung_ac_samsung_ac_mode_select);
DEBUG Adding: samsung_ac_samsung_ac_mode_select->set_name("main_bedroom_mode");
DEBUG Adding: samsung_ac_samsung_ac_mode_select->set_disabled_by_default(false);
DEBUG Adding: samsung_ac_samsung_ac_mode_select->traits.set_options({"Auto", "Cool", "Dry", "Fan", "Heat"});
DEBUG Adding global: mqtt::MQTTSelectComponent *mqtt_mqttselectcomponent;
DEBUG Adding: mqtt_mqttselectcomponent = new mqtt::MQTTSelectComponent(samsung_ac_samsung_ac_mode_select);
ERROR ID mqtt_mqttselectcomponent is already registered
Traceback (most recent call last):
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/__main__.py", line 947, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/__main__.py", line 355, in command_compile
    exit_code = write_cpp(config)
                ^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/__main__.py", line 176, in write_cpp
    generate_cpp_contents(config)
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/__main__.py", line 188, in generate_cpp_contents
    CORE.flush_tasks()
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/core/__init__.py", line 616, in flush_tasks
    self.event_loop.flush_tasks()
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/coroutine.py", line 246, in flush_tasks
    next(task.iterator)
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/__main__.py", line 168, in wrapped
    await coro(conf)
  File "/Users/sredfern/projects/esp_samsung/.esphome/external_components/11b80f5a/components/samsung_ac/__init__.py", line 135, in to_code
    await select.register_select(sel, conf, options=values)
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/components/select/__init__.py", line 82, in register_select
    await setup_select_core_(var, config, options=options)
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/components/select/__init__.py", line 74, in setup_select_core_
    mqtt_ = cg.new_Pvariable(config[CONF_MQTT_ID], var)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/cpp_generator.py", line 578, in new_Pvariable
    return Pvariable(id_, rhs)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/cpp_generator.py", line 560, in Pvariable
    CORE.register_variable(id_, obj)
  File "/usr/local/Cellar/esphome/2022.12.5/libexec/lib/python3.11/site-packages/esphome/core/__init__.py", line 746, in register_variable
    raise EsphomeError(f"ID {id} is already registered")
esphome.core.EsphomeError: ID mqtt_mqttselectcomponent is already registered

Looks like it might be a problem related to the fact I have a 3 head unit rather than a single one?

@bzumik1 - Could you try on your instance and see if it gets an early error?

@lanwin
Copy link
Collaborator

lanwin commented Nov 15, 2023

What do you mean by 3 head units?

@lanwin
Copy link
Collaborator

lanwin commented Nov 15, 2023

Can you post your full yaml. I want to try if I get the same error there.

@sredfern
Copy link

Hi Steve,

By 3 head units I mean I have 3 indoor devices.

Below is my configuration. Thank you for your help.

esphome:
  name: samsung-ac-control

esp32:
  board: nodemcu-32s

substitutions:
# Change the disp_name to something you want  
  unit00: main_bedroom
  unit01: kids_bedroom
  unit02: livingroom



# Enable logging
logger:


external_components:
  - source: github://lanwin/esphome_samsung_ac@main
    components: [samsung_ac]

# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""


wifi:
  ssid: "aasdfasdfasfd"
  password: "asdfasfdasfe"


mqtt:
  broker: 192.168.
  username: samsung_ac
  password: passwd
  discovery: false

captive_portal:
    
web_server:
  port: 80


uart:
  tx_pin: GPIO26
  rx_pin: GPIO18
  rx_buffer_size: 1024
  baud_rate: 9600
  parity: EVEN

samsung_ac:
  devices:
    - address: "20.00.00"
      climate:
        name: "${unit00} Heat Pump"
      room_temperature:
        name: ${unit00}_room_temp
      target_temperature:
        name: ${unit00}_target_temp
      power:
        name: ${unit00}_power
      mode:
        name: ${unit00}_mode
      room_humidity:
        name: ${unit00}_room_humidity
    - address: "20.00.01"
      climate:
        name: "${unit01} Heat Pump"
      room_temperature:
        name: ${unit01}_room_temp
      target_temperature:
        name: ${unit01}_target_temp
      power:
        name: ${unit01}_power
      mode:
        name: ${unit01}_mode
      room_humidity:
        name: ${unit01}_room_humidity
    - address: "20.00.02"
      climate:
        name: "${unit02} Heat Pump"
      room_temperature:
        name: ${unit02}_room_temp
      target_temperature:
        name: ${unit02}_target_temp
      power:
        name: ${unit02}_power
      mode:
        name: ${unit02}_mode
      room_humidity:
        name: ${unit02}_room_humidity

@lanwin
Copy link
Collaborator

lanwin commented Nov 16, 2023

When you remove the mode: parts it works. I am not sure why this is. Seems to be some special magic for the MQTT parts behind the scenes.

@sredfern
Copy link

Hi Steve, thanks for debugging this with me.

I can see some data in MQTT but nothing relating to the test/nasa structure you've made here here

Screenshot 2023-11-17 at 11 36 46 pm

I would be expecting to see a test topic. Searching within the structure shows nothing as well.

@lanwin
Copy link
Collaborator

lanwin commented Nov 19, 2023

Hi Steve, thanks for debugging this with me.

I can see some data in MQTT but nothing relating to the test/nasa structure you've made here here
Screenshot 2023-11-17 at 11 36 46 pm

I would be expecting to see a test topic. Searching within the structure shows nothing as well.

But you see incoming data within the log?

@sredfern
Copy link

I’m not sure I can. This is the two parts of the logs I think is relevant:
E2D69ED1-7C27-4C99-9355-270993176C18
77EF6C8E-A645-4A22-8FB5-A2668F505A6B

I can see all the HA presented values being transmitted to mqtt. I’m unable to see any of the codes and values.

FYI, I’m travelling for work so this post isn’t as detailed as I would have liked. Thank you for all your help here Steve.

@lanwin
Copy link
Collaborator

lanwin commented Nov 30, 2023

@ALL I have chaneged the MQTT stuff. It turns out the integrated MQTT component produced raceconditions when its sends its own data and so a lot of garbage is created in my MQTT server. So I build in an custom mqtt client.

You can configure it like so:

samsung_ac:
  debug_mqtt_host: {ip}
  debug_mqtt_port: 1883
  debug_mqtt_username: {username}
  debug_mqtt_password: {password}
  ....

@sredfern
Copy link

Hi Steve, back from travel. Great to see your progress with debugging tools. Thanks so much for all the work you have put in here, I really appreciate it.

I have been playing around with it on my end and the problem I'm coming up with is the client never connects. What's more strange is if I configure ESPHome's MQTT interface I can see it connect:

From yaml

mqtt:
  broker: 192.168.86.141
  username: samsung_ac
  password: passwd
  discovery: false

from Mosquitto logs

2023-12-09 15:12:23: New connection from 192.168.86.188:63147 on port 1883.
2023-12-09 15:12:23: New client connected from 192.168.86.188:63147 as samsung-ac-control-d4d4da83e554 (p2, c0, k15, u'samsung_ac').

From there, I can see the usual output you expect from connecting a esphome client to an MQTT instance.
Screenshot 2023-12-09 at 3 13 08 pm

However, when I remove the esphome native MQTT configuration and put the configuration into the samsung_ac part of the config:

samsung_ac:
  debug_mqtt_host: 192.168.86.141
  debug_mqtt_port: 1883
  debug_mqtt_username: samsung_ac
  debug_mqtt_password: passwd
  debug_log_messages: false # logs all messages - only for debugging
  debug_log_messages_raw: false # logs the raw message bytes from all messages - only for debugging

I get nothing in the log from the Mosquitto logs.

I have a question - It seems like in debug_mqtt.cpp you're using USE_ESP8266 that only runs the code if you're running an 8266. Would this execute with an esp32?

I'm using a ESP32 so that could be why it won't connect to my MQTT instance.

Let me know your thoughts. Thanks

@Foxhill67
Copy link

Hi Steve, thanks for the great work done so far! I am setting up an ESP32 / TTL to RS485 system to monitor my Samsung EHS heatpump (inside AE260RNWSGG/EU outside AE090RXEDGG/EU).

I too do not see a connection made to my MQTT instance, probably because in debug_mqtt.cpp a connection is only made if USE_ESP8266 is defined (which clearly is not the case when using an ESP32)?

@lanwin
Copy link
Collaborator

lanwin commented Dec 11, 2023

Yes it is true. Currently the code only works with ESP8266 cause for ESP32 I need to use another client. Did not tried that yet.

@lanwin
Copy link
Collaborator

lanwin commented Jan 2, 2024

I added support for ESP32. But I am not able to test it, since I have no ESP32 here. So please try.

@Foxhill67
Copy link

Tested with ESP32 but get compile errors:
logs_esp-samsung-ehs_run.txt

May be #include "mqtt_client.h" is missing? See https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/protocols/mqtt.html

@lanwin
Copy link
Collaborator

lanwin commented Jan 2, 2024

Ah sorry I compiled against the wrong code and did not noticed the build errors. Now it should compile.

@Foxhill67
Copy link

Yes, now works like a charm! tnxs.

@sredfern
Copy link

sredfern commented Jan 5, 2024

@lanwin - Can confirm working like a charm. Have started dumping the data for analysis.
Screenshot 2024-01-05 at 4 36 29 pm

FYI I have a fork I'm exploring to also add in the device from and to as part of the topic in MQTT. You can check it out here. If I find it useful I'll create a PR to this project.

@lanwin
Copy link
Collaborator

lanwin commented Jan 5, 2024

Sounds good! 👍🏻

@mbo18
Copy link
Contributor

mbo18 commented Feb 2, 2024

Just updated all my ESP and I now have this in my ESP logs:

[17:21:49][W][samsung_ac:560]: s:10.00.00 d:b0.00.ff NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT  30.000000
[17:21:49][W][samsung_ac:554]: s:10.00.00 d:b0.00.ff LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM 30.000000
[17:21:49][W][samsung_ac:547]: s:10.00.00 d:b0.00.ff LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM 1589.247000kwh

Does that means that you will be able to add power consumption sensors??
Would be really nice.

EDIT:
NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT seems to be outdoor unit current power consumption:

state_class: measurement
unit_of_measurement: W
device_class: power

LVAR_OUT_CONTROL_WATTMETER_1W_1MIN_SUM seems to be the sum of all unit current power consumption (but as I have only 1 indoor unit it is equal to NASA_OUTDOOR_CONTROL_WATTMETER_1UNIT here):

state_class: measurement
unit_of_measurement: W
device_class: power

LVAR_OUT_CONTROL_WATTMETER_ALL_UNIT_ACCUM is total energy:

state_class: total_increasing
unit_of_measurement: kWh
device_class: energy 
``

@lanwin
Copy link
Collaborator

lanwin commented Feb 2, 2024

Yes I added test code to check if there are coming valid data since @Foxhill67 has provided the corresponding here #28

@atanasenko
Copy link
Contributor

This is currently my configuration for electricity/power related sensors for outdoor unit AJ068TXJ3KG/EU:

  devices:
    - address: "10.00.00"
      outdoor_temperature:
        name: AC Outdoor temperature
      custom_sensor:
        - name: AC Voltage
          message: 0x24fc
          device_class: voltage
          state_class: measurement
          unit_of_measurement: V
        - name: AC Current
          message: 0x8217
          device_class: current
          state_class: measurement
          unit_of_measurement: A
          accuracy_decimals: 1
          filters:
            - multiply: 0.1
        - name: AC Power
          message: 0x8413
          device_class: energy
          state_class: measurement
          unit_of_measurement: W
        - name: AC Energy
          message: 0x8414
          device_class: energy
          state_class: total_increasing
          unit_of_measurement: KWh
          accuracy_decimals: 1
          filters:
            - multiply: 0.001

@mbo18
Copy link
Contributor

mbo18 commented Mar 6, 2024

Hi @lanwin,

Is atanasenko way of adding power sensors the official way or do you plan to add power sensors in a future release?
Also do you plan to do another stable release shortly? There does not seems to be issue with the current code

@starsalmon
Copy link

This is currently my configuration for electricity/power related sensors for outdoor unit AJ068TXJ3KG/EU:

  devices:
    - address: "10.00.00"
      outdoor_temperature:
        name: AC Outdoor temperature
      custom_sensor:
        - name: AC Voltage
          message: 0x24fc
          device_class: voltage
          state_class: measurement
          unit_of_measurement: V
        - name: AC Current
          message: 0x8217
          device_class: current
          state_class: measurement
          unit_of_measurement: A
          accuracy_decimals: 1
          filters:
            - multiply: 0.1
        - name: AC Power
          message: 0x8413
          device_class: energy
          state_class: measurement
          unit_of_measurement: W
        - name: AC Energy
          message: 0x8414
          device_class: energy
          state_class: total_increasing
          unit_of_measurement: KWh
          accuracy_decimals: 1
          filters:
            - multiply: 0.001

Thank you so much, I could see the readings in the logs but had no idea how to use them as entities. 2 small issues for anyone copy pasting this:
AC Power should be device_class: power
AC energy unit_of_measurement needs to be kWh instead of KWh

@Tycorc
Copy link

Tycorc commented May 25, 2024

Can also confirm the custom sensor config from @mbo18 works perfectly fine with my AJ050TXJ2KG

@bzumik1
Copy link
Contributor Author

bzumik1 commented May 25, 2024

I can confirm that all sensors work on my AJ050TXJ2KG. Would it be possible to introduce these sensors “normally” and not as custom sensors to make it easier for others?

I also have a question regarding the consumption. In the Samsung app, I see the consumption separated for each indoor device. Is this also available in the NASA protocol, or is it just an estimation in the Samsung app?

P.S. now I have noticed that I have exactly same outdoor unit as @Tycorc

@lanwin
Copy link
Collaborator

lanwin commented May 27, 2024

Hi @lanwin,

Is atanasenko way of adding power sensors the official way or do you plan to add power sensors in a future release? Also do you plan to do another stable release shortly? There does not seems to be issue with the current code

No I would want to add them as controls/sensors natively.

First this would allow to use them from non nasa too.

And secondly I think this is far more straight forward for most users.

But that have to wait. There is just too much other stuff on my desk.

@mbo18
Copy link
Contributor

mbo18 commented May 30, 2024

This is my configuration for AR09TXCAAWKNEU and AR12TXCAAWKNEU:

samsung_ac:
  capabilities:
    vertical_swing: true
    horizontal_swing: true
    presets: 
      quiet: true
      windfree: true
      fast: true
  devices:
    - address: "20.00.00"
      climate:
        name: None
    - address: "10.00.00"
      outdoor_temperature:
        name: "Outdoor temperature"
      custom_sensor:
        - name: Power
          message: 0x8413
          device_class: power
          state_class: measurement
          unit_of_measurement: W
        - name: Energy
          message: 0x8414
          device_class: energy
          state_class: total_increasing
          unit_of_measurement: kWh
          accuracy_decimals: 2
          filters:
            - multiply: 0.001

No voltage or current on these models

@bzumik1
Copy link
Contributor Author

bzumik1 commented Jul 27, 2024

Have anyone find out how to measure independent consumption of internal units? The WiFi kit supports that.

Edit: I see I have already ask, sorry for duplicate question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
9 participants