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

[nextion] Add publish actions #7646

Merged
merged 8 commits into from
Nov 23, 2024
Merged

[nextion] Add publish actions #7646

merged 8 commits into from
Nov 23, 2024

Conversation

pkejval
Copy link
Contributor

@pkejval pkejval commented Oct 21, 2024

What does this implement/fix?

Adds YAML actions for publishing states of various Nextion sensors. This functionality was available only in lambdas.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

none

Pull request in esphome-docs with documentation (if applicable):

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

esphome:
  name: test2
  on_boot: 
    then:
      - sensor.nextion.publish:
          id: nex_float
          state: 1
          publish_state: false
          send_to_nextion: true

      - binary_sensor.nextion.publish:
          id: nex_binary
          state: True

      - text_sensor.nextion.publish:
          id: nex_text
          state: "TEST"

      - switch.nextion.publish:
          id: nex_switch
          state: True

esp32:
  board: wemos_d1_mini32
  framework:
    type: esp-idf

logger:
api:
ota:
  platform: esphome

wifi:
  ssid: !secret wifi
  password: !secret wifi_pass
  reboot_timeout: 0s

external_components:
  - source: github://pr#7646
    components: [ nextion ]

sensor:
  - platform: nextion
    id: nex_float
    nextion_id: nex
    component_name: test.float
    precision: 0

binary_sensor:
  - platform: nextion
    id: nex_binary
    component_name: test.binary

text_sensor:
  - platform: nextion
    id: nex_text
    component_name: test.text

switch:
  - platform: nextion
    id: nex_switch
    component_name: test.switch

uart:
  - id: ser
    rx_pin: GPIO16
    tx_pin: GPIO17
    baud_rate: 115200

display:
  - platform: nextion
    id: nex
    uart_id: ser

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@probot-esphome
Copy link

Hey there @edwardtfn, @SenexCrenshaw, mind taking a look at this pull request as it has been labeled with an integration (nextion) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@codecov-commenter
Copy link

codecov-commenter commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.76%. Comparing base (4d8b5ed) to head (bb00644).
Report is 1639 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #7646      +/-   ##
==========================================
+ Coverage   53.70%   53.76%   +0.05%     
==========================================
  Files          50       50              
  Lines        9408     9805     +397     
  Branches     1654     1354     -300     
==========================================
+ Hits         5053     5272     +219     
- Misses       4056     4207     +151     
- Partials      299      326      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

kbx81
kbx81 previously approved these changes Oct 24, 2024
Copy link
Member

@kbx81 kbx81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- @edwardtfn any thoughts/comments?

@edwardtfn
Copy link
Contributor

It looks awesome.

@kbx81
Copy link
Member

kbx81 commented Oct 30, 2024

One final thought/request @pkejval -- please update the tests for this component to include these actions.

@kbx81 kbx81 dismissed their stale review October 30, 2024 04:28

Needs tests updated

@pkejval
Copy link
Contributor Author

pkejval commented Nov 1, 2024

I wrote some tests but I have no idea how to run them. Cannot find any documentation about it. Can you give me advice, please?

@kbx81
Copy link
Member

kbx81 commented Nov 3, 2024

From the root of the repo: ./script/test_build_components -e compile -c nextion

Copy link
Member

@kbx81 kbx81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes so tests will work

tests/components/nextion/test.esp32-ard.yaml Outdated Show resolved Hide resolved
tests/components/nextion/test.esp32-c3-ard.yaml Outdated Show resolved Hide resolved
tests/components/nextion/test.esp32-c3-idf.yaml Outdated Show resolved Hide resolved
tests/components/nextion/test.esp32-idf.yaml Outdated Show resolved Hide resolved
tests/components/nextion/test.esp8266-ard.yaml Outdated Show resolved Hide resolved
tests/components/nextion/test.rp2040-ard.yaml Outdated Show resolved Hide resolved
@esphome esphome bot marked this pull request as draft November 17, 2024 07:36
@esphome
Copy link

esphome bot commented Nov 17, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Copy link
Member

@kbx81 kbx81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix binary sensor IDs in tests

tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
tests/components/nextion/common.yaml Outdated Show resolved Hide resolved
on_page:
then:
lambda: 'ESP_LOGD("display","Display shows new page %u", x);'
wifi: !remove
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP client requires wifi

@kbx81 kbx81 changed the title Add Nextion actions [nextion] Add publish actions Nov 17, 2024
@kbx81 kbx81 marked this pull request as ready for review November 17, 2024 09:02
@esphome esphome bot requested a review from kbx81 November 17, 2024 09:02
@probot-esphome
Copy link

Hey there @SenexCrenshaw, mind taking a look at this pull request as it has been labeled with an integration (nextion) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

kbx81
kbx81 previously approved these changes Nov 17, 2024
Copy link
Member

@kbx81 kbx81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- thanks!

@kbx81 kbx81 merged commit dea297c into esphome:dev Nov 23, 2024
26 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants