Question about clock plugin

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Question about clock plugin

#1 Post by chromo23 » 03 Dec 2023, 09:46

If no pin is enabled in the clock plugin it gives you the possibility to enter values.
What are these values for?

When i enter a time and a value (e.g. 43) i get this.

Code: Select all

85234186: TCLK : State 43
85234188: EVENT: Clock#Time=Sun,8:42
85234191: EVENT: Clock#output=1
What is TCLK for and why it the clock output 1?

Edit: When i enter 0 as a value the output doesn´t change. I would have thought, that it turns the output to zero but it doesn´t even create an event...

User avatar
Ath
Normal user
Posts: 3918
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Question about clock plugin

#2 Post by Ath » 03 Dec 2023, 15:28

The code of that plugin is a bit confusing.
These actions only apply if a configured value is set:
- If a GPIO pin is configured, you will get the index of the configured clock-trigger
- if NO GPIO pin is configured, the output is set to the index of the configured clock-trigger, and output2 is set to the configured value.
- That state value is always logged as TCLK

There hasn't been any structural change on this plugin for a long time (only occasional code-improvement maintenance), so it must work for its purpose ;).
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Question about clock plugin

#3 Post by chromo23 » 03 Dec 2023, 19:23

Ok...thanks for clarification. It also help with understanding the code structure a bit better.
I don't see the added value though. It is somehow counterintuitive and confusing. :shock:
By the way... i want to experiment a bit. Can you point me in the right direction for adding the ability to set (and maybe read) the values via html request? Or is it too hard to accomplish because the structure doesn´t allow it?

User avatar
Ath
Normal user
Posts: 3918
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Question about clock plugin

#4 Post by Ath » 03 Dec 2023, 20:34

chromo23 wrote: 03 Dec 2023, 19:23 By the way... i want to experiment a bit. Can you point me in the right direction for adding the ability to set (and maybe read) the values via html request? Or is it too hard to accomplish because the structure doesn´t allow it?
That should best be done via the PLUGIN_SET_CONFIG, or PLUGIN_WRITE, and PLUGIN_GET_CONFIG_VALUE functions in the plugin. There are several examples available, f.e. in P021 (*_SET_*), P104 (*_WRITE), and P008, P021, P026 etc. (*_GET_*). The command to set a value is config, like:

Code: Select all

config,task,<taskname>,setwhatever,<value>
the "setwhatever" part is different per plugin and what value you want to implement/set. The 'set' prefix isn't mandatory, or maybe not even desirable, IMHO, the 'config' part of the command already implies you're changing something :)

To get a value via the *_GET_* function is just by using the usual [<taskname>#<valuename>], where you handle the <valuename> part. It's easiest to have unique value names from the regular value names, so 'output' wouldn't be the happiest choice ;)

For using the PLUGIN_WRITE method you can be as creative as you want, taking from the many examples.

Import issue to take with you is that saving the data to flash should best be a separate command to send from remote (the global save command will do perfectly fine, no need to implement that in a plugin, P021 is a real exception, but mostly for historical reasons). And saving should be as sparse as possible, to not wear out the flash.

And, of course, when you need more detailed help, just ask :D
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Question about clock plugin

#5 Post by chromo23 » 03 Dec 2023, 21:13

Thank you very much for the detailed answer...
I'll do a bit of research and see if i understand and possibly can implement this. :)

User avatar
Ath
Normal user
Posts: 3918
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Question about clock plugin

#6 Post by Ath » 03 Dec 2023, 21:29

/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Question about clock plugin

#7 Post by chromo23 » 03 Dec 2023, 21:34

Ath wrote: 03 Dec 2023, 21:29 https://espeasy.readthedocs.io/en/lates ... ormIO.html
this is fortunately nothing new for me ;)

User avatar
Ath
Normal user
Posts: 3918
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Question about clock plugin

#8 Post by Ath » 05 Dec 2023, 23:13

Also see this FR (that's probably not going to be honored :o)
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3918
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Question about clock plugin

#9 Post by Ath » 11 Dec 2023, 23:19

Ath wrote: 05 Dec 2023, 23:13 Also see this FR (that's probably not going to be honored :o)
Well, that turned out a bit different :lol:

Now I only need the specs of what values you need to set/get from this plugin (set: "Value X"? "Day,Time X"?, get: ??), and a suggestion for the command name, as 'clock' doesn't sound like the best choice here...
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Question about clock plugin

#10 Post by chromo23 » 12 Dec 2023, 23:23

Ath wrote: 11 Dec 2023, 23:19 Now I only need the specs of what values you need to set/get from this plugin
Wow.. i missed that post and really did not expect this. Great news.
I´ll think about it tomorrow and hope I'll still catch you before you loose interest and energy for this plugin...
Good night!

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Question about clock plugin

#11 Post by chromo23 » 13 Dec 2023, 20:22

Ath wrote: 11 Dec 2023, 23:19 (set: "Value X"? "Day,Time X"?, get: ??), and a suggestion for the command name, as 'clock' doesn't sound like the best choice here...
I am not sure if we have a already a generic syntax for setting plugins.. but if i would probably stick to the syntax of the level control plugin?

Like:

Code: Select all

config,task,<taskname>,SetTime,"1,Mon,12:00,1"
(the last number stands for 1=on and 0= off or if in"value-mode" for the value)

About reading probably the same:

Code: Select all

[<taskname>#GetTimeX] 
where X is the timeslot


Another question about reading values:
Values of Plugins are stored in config.dat, right?
Is ist possible to convert the content into something human readable or passing it to another porgram to be parsed there?

User avatar
Ath
Normal user
Posts: 3918
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Question about clock plugin

#12 Post by Ath » 16 Dec 2023, 21:17

@Chromo23 I've added the features for setting and getting the configured time and value to PR #4903. Unfortunately the build failed for size reasons on the alt_wifi_ESP8266 environment, but most binaries are available from the Actions run. You know how to handle that ;)
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 842
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Question about clock plugin

#13 Post by chromo23 » 16 Dec 2023, 21:32

Already tested it... :)

Looks good...apart this annoying size restriction... who builds microcontroller with this tiny amount of memory.. tzzzz

Edit: not tested...still testing.....

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests