Skip to content

Conversation

@apo-mak
Copy link

@apo-mak apo-mak commented Dec 8, 2025

This pull request introduces new switch controls and configuration improvements to all four ultimatesensor-v1 YAML files, enhancing user control over the OLED display, PM sensor, and adding a night mode feature. The changes improve modularity and allow users to enable/disable hardware features dynamically.

Switch Controls and Feature Toggles:

  • Added a template switch for the OLED display (lcd_display_switch) in all variants, allowing users to turn the display on or off via software. ([[1]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-a3770364b76f54f220ce4aaacea9e29ed3565ed2bf44624610833693d617bda9R847-R860), [[2]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-8c709a45ae1fcc1c41cba43ff0ea2a90aa3820fb34e655e332429506c56a2316R850-R863), [[3]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-eee30ec6755c8a53ad71061a470d33e686ca0bda6707cb407cb2c522e455b334R914-R958), [[4]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-88da9783ffb25c7106ab4ecb1b9db30e14cabc15050b8b30b08f635b7391bc2dR887-R931))
  • Introduced a template switch for the PM sensor (pm_sensor_switch) in the "complete" variants, enabling dynamic activation or deactivation of the sensor and its update interval. ([[1]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-eee30ec6755c8a53ad71061a470d33e686ca0bda6707cb407cb2c522e455b334R914-R958), [[2]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-88da9783ffb25c7106ab4ecb1b9db30e14cabc15050b8b30b08f635b7391bc2dR887-R931))
  • Added a "Night Mode" switch in the "complete" variants, which simultaneously disables/enables both the display and PM sensor for low-power or night-time operation. ([[1]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-eee30ec6755c8a53ad71061a470d33e686ca0bda6707cb407cb2c522e455b334R914-R958), [[2]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-88da9783ffb25c7106ab4ecb1b9db30e14cabc15050b8b30b08f635b7391bc2dR887-R931))

Sensor and Display Configuration:

  • Assigned unique IDs to the OLED display (id: oled_display) in all YAML files, enabling direct reference and control from other components. ([[1]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-a3770364b76f54f220ce4aaacea9e29ed3565ed2bf44624610833693d617bda9R90), [[2]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-8c709a45ae1fcc1c41cba43ff0ea2a90aa3820fb34e655e332429506c56a2316R93), [[3]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-eee30ec6755c8a53ad71061a470d33e686ca0bda6707cb407cb2c522e455b334R108), [[4]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-88da9783ffb25c7106ab4ecb1b9db30e14cabc15050b8b30b08f635b7391bc2dR90))
  • Added an ID to the PM sensor (id: pm_sensor) in the "complete" variants for easier management and integration with switches. ([[1]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-eee30ec6755c8a53ad71061a470d33e686ca0bda6707cb407cb2c522e455b334R170), [[2]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-88da9783ffb25c7106ab4ecb1b9db30e14cabc15050b8b30b08f635b7391bc2dR151))

Global State Management:

  • Introduced a global variable (pm_sensor_enabled) in the "complete" variants to persist the enabled/disabled state of the PM sensor across restarts. ([[1]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-eee30ec6755c8a53ad71061a470d33e686ca0bda6707cb407cb2c522e455b334R353-R356), [[2]](https://github.com/smarthomeshop/ultimatesensor/pull/4/files#diff-88da9783ffb25c7106ab4ecb1b9db30e14cabc15050b8b30b08f635b7391bc2dR334-R337))

Copilot AI and others added 2 commits December 7, 2025 23:38
Co-authored-by: apo-mak <25563515+apo-mak@users.noreply.github.com>
@dwainscheeren
Copy link
Member

Seems like the switch to toggle off the pm sensor does not work, did you test it?

@apo-mak
Copy link
Author

apo-mak commented Dec 9, 2025

Seems like the switch to toggle off the pm sensor does not work, did you test it?

yes and i thought that it works.
It looks like the function command does not work reliably or it was a fluke so I have replaced it with a direct I2C command.

@taacton
Copy link

taacton commented Dec 15, 2025

I tested .turn_on() and .turn_off() for the display and it didn't work. I was able to create a switch in the UI that toggles the contrast between 0% and 40% which has a similar effect. I'm just about to create a PR for this now.

@dwainscheeren
Copy link
Member

Very strange because it works here on my Ultimate Sensor turning on and off the display

@apo-mak
Copy link
Author

apo-mak commented Dec 15, 2025

I tested .turn_on() and .turn_off() for the display and it didn't work. I was able to create a switch in the UI that toggles the contrast between 0% and 40% which has a similar effect. I'm just about to create a PR for this now.

it works on my end, especially the "night mode.
can you try re-flashing it? do you see any logs when you toggle it ?

@apo-mak
Copy link
Author

apo-mak commented Dec 16, 2025

@dwainscheeren is it ok to merge this pr ?
did you encounter any problems with this build ?

@dwainscheeren
Copy link
Member

Let me check, there are now 2 PR's for the same thing :P Let me check what is the best I can do and merge it.

@apo-mak
Copy link
Author

apo-mak commented Dec 17, 2025

Let me check, there are now 2 PR's for the same thing :P Let me check what is the best I can do and merge it.

Quick note, the other PR is only for the display.
This one also stops the PM sensor because the fan is very noisy at night.

So if you go with the other one, please copy the “PM turn off” part of the code ( and or the night switch for the Home Assistant)
:)

@dwainscheeren
Copy link
Member

Yes but esphome released an update with also sps30 idle mode now :) so need to look into that also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants