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

custom variables #1423

Closed
proddy opened this issue Nov 13, 2023 · 8 comments
Closed

custom variables #1423

proddy opened this issue Nov 13, 2023 · 8 comments
Labels
enhancement New feature or request
Milestone

Comments

@proddy
Copy link
Contributor

proddy commented Nov 13, 2023

From a discussion with Michael:

The scheduler have entity/command to activate/deactivate the schedule. This was for replace the forceheatingoff, sending selflowtemp 0 every minute to stop the boiler, and disable scheduler to activate the boiler again.
Maybe it's a nice addition to also manipulate the schedule command value via command. But difficult to add in the command structure.

I wonder if we can add custom RAM entities only stored in ems-esp and use them for setting a variable value. E.g. in custom use devcie/telegram type 0x0 for storing 256 bytes. Custom entity: myseltemp, device 0, type 0, offset 0, UINT, Scheduler: every minute, command: boiler/seltemp, value: custom/myseltemp. Then the flowtemp can be set via mqtt: custom/myseltemp and is used by the scheduler.

Originally posted by @MichaelDvP in #1418 (comment)

@proddy
Copy link
Contributor Author

proddy commented Nov 13, 2023

I see, That's quite clever. How about instead of using custom entities to store variables we could create a new type called Variables. Maybe limit to 10 max, as strings with a default value that is stored in LittleFS and loaded at boot.

@proddy
Copy link
Contributor Author

proddy commented Jan 14, 2024

Something like:

  • In the Custom Entity web page you can choose to read/write the value from EMS (with a deviceID, typeID, Offset) or as a Variable with default value. It means extending Custom Entity to include a Custom Entity type, and it's persisted in the FS. The value could be written to NVS or just kept in memory (which means loosing after a reboot)
  • Add a new API call to read or write a value to the Custom Entity
  • Modify the Scheduler to also accept a Custom Entity as a value, instead of a hardcoded value

@MichaelDvP thoughts?

@MichaelDvP
Copy link
Contributor

Comments to:

  1. Custom variable only with name and default value. The value can be stored as string (no need to set the type), the command-values are always processed as char*. Default value should be stored in FS, changing the value by API should only use RAM (to avoid wear of FS). Setting new default only va web page.
  2. API command is already implemented for custom values (call custom <name> <value>, /api/custom/<name> {"value":"<value>"})
  3. The scheduler already accepts commands (that return a value) as value. e.g. boiler/flowtemp/value returns the actual flowtemp can be processed as value parameter.

@proddy
Copy link
Contributor Author

proddy commented Jan 14, 2024

excellent, so we only need to implement #1 !

MichaelDvP added a commit to MichaelDvP/EMS-ESP32 that referenced this issue Jan 20, 2024
proddy added a commit that referenced this issue Jan 20, 2024
@proddy proddy modified the milestones: v3.7.0, v3.6.5 Jan 22, 2024
@proddy
Copy link
Contributor Author

proddy commented Jan 22, 2024

@MichaelDvP my idea with Variables was to be able to use them in Values

For example if I created a custom entity called 'foo' I could use this in the Scheduler as a value like {foo}, so its dynamic/variable and not static/hardcoded.

@MichaelDvP
Copy link
Contributor

The value is in ram and can be accessed. The typical example to set the boiler flowtemp without thermostat.
Setting boiler/selflowtemp resets after 1minute, so the user has to repeat it often. We can do this with scheduler, but need a dynamic value in scheduler. Steps are now:

  • create custom entityas RAM value selflowtemp
  • create scheduler with timer 1 minute for command boiler/selflowtemp, value: custom/selflowtemp/value
    Now you can use the single command (API/mqtt/console) custom/selflowtemp with new value 40 and this is repeated by the scheduler every minute.

@proddy
Copy link
Contributor Author

proddy commented Jan 22, 2024

I didn't realize that, I need to look at the code again. I thought WebSchedulerService::command() just called the command. But cool!

@proddy
Copy link
Contributor Author

proddy commented Feb 4, 2024

tested, works great. I'll add some notes to the doc.

@proddy proddy closed this as completed Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants