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

Method to retrieve ALL possible GPIO components via MQTT, including assigned #6407

Closed
jziolkowski opened this issue Sep 12, 2019 · 13 comments
Closed
Labels
enhancement Type - Enhancement that will be worked on

Comments

@jziolkowski
Copy link
Contributor

The command "gpios" returns all components but without those assigned in module config or template. To be able to edit templates externally, this needs extra work to compile a complete list.

Such list of all available GPIOs (including these assigned) is available in the comboboxes in template edit - could it be available via MQTT? Maybe just adding a parameter to existing command, or a whole new command? That would greatly help external management tools (like TDM wink wink nudge nudge)

@arendst
Copy link
Owner

arendst commented Sep 12, 2019

Not all GPIO are available in all compilations. Depending on defines enabled many GPIO's are not present so your list will almost never be complete.

The ones assigned in module config can be shown with command gpio.

@jziolkowski
Copy link
Contributor Author

Yes, I know. That's why I'm polling each device before configuring gpios. I don't want a list of all gpios available in whole Tasmota - but only in that certain device.

@jziolkowski
Copy link
Contributor Author

The comboboxes in template edit shows exactly the data I need - independent of currently used/configured gpios.

@arendst
Copy link
Owner

arendst commented Sep 12, 2019

The template combo box holds exactly the same information as command gpios with an additional User 255

@jziolkowski
Copy link
Contributor Author

I beg to differ.
The output below is from a 3-button device configured via template.

09:24:14 MQT: stat/ds102_chlopcy/RESULT = {"NAME":"DS-102 3 Gang","GPIO":[57,59,0,18,22,19,0,0,17,21,58,25,56],"FLAG":0,"BASE":18}

09:19:14 CMD: gpios
09:19:14 MQT: stat/ds102_chlopcy/RESULT = {"GPIOs1":["0 (None)","20 (Button4)","93 (Button4n)","125 (Button4i)","129 (Button4in)","9 (Switch1)","82 (Switch1n)","10 (Switch2)","83 (Switch2n)","11 (Switch3)","84 (Switch3n)","12 (Switch4)","85 (Switch4n)","13 (Switch5)","86 (Switch5n)","14 (Switch6)","87 (Switch6n)","15 (Switch7)","88 (Switch7n)","16 (Switch8)","89 (Switch8n)","23 (Relay3)","31 (Relay3i)","24 (Relay4)","32 (Relay4i)","26 (Relay6)","34 (Relay6i)"]}
09:19:14 MQT: stat/ds102_chlopcy/RESULT = {"GPIOs2":["27 (Relay7)","35 (Relay7i)","28 (Relay8)","36 (Relay8i)","37 (PWM1)","46 (PWM1i)","38 (PWM2)","47 (PWM2i)","39 (PWM3)","48 (PWM3i)","40 (PWM4)","49 (PWM4i)","41 (PWM5)","50 (PWM5i)","42 (Counter1)","94 (Counter1n)","43 (Counter2)","95 (Counter2n)","44 (Counter3)","96 (Counter3n)","45 (Counter4)","97 (Counter4n)","148 (Serial Tx)","149 (Serial Rx)","5 (I2C SCL)","6 (I2C SDA)","1 (DHT11)","2 (AM2301)","3 (SI7021)"]}
09:19:15 MQT: stat/ds102_chlopcy/RESULT = {"GPIOs3":["4 (DS18x20)","7 (WS2812)","8 (IRsend)","51 (IRrecv)","105 (RFSend)","106 (RFrecv)","73 (SR04 Tri)","74 (SR04 Ech)","102 (HX711 SCK)","103 (HX711 DAT)","130 (HLWBL SEL)","131 (HLWBL SELi)","132 (HLWBL CF1)","133 (HLW8012 CF)","134 (BL0937 CF)","156 (ADE7953 IRQ)","145 (CSE7766 Tx)","146 (CSE7766 Rx)","135 (MCP39F5 Tx)","136 (MCP39F5 Rx)","137 (MCP39F5 Rst)","62 (PZEM0XX Tx)","63 (PZEM004 Rx)","98 (PZEM016 Rx)"]}
09:19:15 MQT: stat/ds102_chlopcy/RESULT = {"GPIOs4":["99 (PZEM017 Rx)","71 (SerBr Tx)","72 (SerBr Rx)","60 (MHZ Tx)","61 (MHZ Rx)","64 (SAir Tx)","65 (SAir Rx)","101 (SDS0X1 Tx)","70 (SDS0X1 Rx)","69 (PMS5003)","104 (TX20)","107 (Tuya Tx)","108 (Tuya Rx)","143 (MY92x1 DI)","144 (MY92x1 DCKI)","140 (SM16716 CLK)","141 (SM16716 DAT)","142 (SM16716 PWR)","147 (ALux IrRcv)"]}

09:19:29 CMD: gpio
09:19:29 MQT: stat/ds102_chlopcy/RESULT = {"GPIO":"Not supported"}

However, at the same time, I can see all the GPIOs in the template editor:
image

(ignore that I have Relay5 instead of Relay3, it's for testing purposes)

@jziolkowski
Copy link
Contributor Author

Also, it would be so nice if the GPIOs JSON output would be a dict keyed with gpio id, instead of flat list, but one can only dream :)

@arendst
Copy link
Owner

arendst commented Sep 12, 2019

Ha, got it.

Will see.

@arendst arendst added the enhancement Type - Enhancement that will be worked on label Sep 12, 2019
@arendst
Copy link
Owner

arendst commented Sep 12, 2019

What format would you like the dict keyed to look like?

@jziolkowski
Copy link
Contributor Author

jziolkowski commented Sep 12, 2019

Oh, you spoil me.

Maybe something like this:

{"GPIOs1": {"0": "None", "20": "Button4", "93": "Button4n", "125": "Button4i", "129": "Button4in", "9": "Switch1", "82": "Switch1n", "10": "Switch2", "83": "Switch2n", "11": "Switch3", "84": "Switch3n", "12": "Switch4", "85": "Switch4n", "13": "Switch5", "86": "Switch5n", "14": "Switch6", "87": "Switch6n", "15": "Switch7", "88": "Switch7n", "16": "Switch8", "89": "Switch8n", "23": "Relay3", "31": "Relay3i", "24": "Relay4", "32": "Relay4i", "26": "Relay6", "34": "Relay6i"} }

etc

IF the modules JSON output would follow suit it would be too good to be true ;)

arendst added a commit that referenced this issue Sep 12, 2019
Add command Gpios 255/All to show all available GPIO components (#6407)
@arendst
Copy link
Owner

arendst commented Sep 12, 2019

For now you'll have to deal with the old output format ;-)

@jziolkowski
Copy link
Contributor Author

Hehe noticed, I'm reading the commit. Thanks a lot anyways. New output is just cosmetics, because it's easy to parse as-is.

This commit was the main request and it finally allows templates to be edited using external tools. Thanks a lot!

@arendst
Copy link
Owner

arendst commented Sep 12, 2019

I'll change the ouput too as I noticed it is more readable and also not longer than the original.

Hold on.

arendst added a commit that referenced this issue Sep 12, 2019
Change JSON output format for commands Adc, Adcs, Modules, Gpio and Gpios from list to dictionary (#6407)
@jziolkowski
Copy link
Contributor Author

Yes, removing the brackets saves quite a few bytes in the whole payload.
Thanks again for this, makes it much easier for tool makers.

arendst added a commit that referenced this issue Oct 10, 2019
Add command Gpio 255 to show physical GPIO configuration of all non-flash pins (#6407)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type - Enhancement that will be worked on
Projects
None yet
Development

No branches or pull requests

2 participants