Open jmbinette opened 4 years ago
It’s already supported. The way to do this would be -
You create 6 ST virtual switches one each for each channel.
As long as you have a tasmota template or your own custom template in tasmota for the 6 ch device :
Then tasmota publishes / subscribes to For channel 1 Stat/blah blah/power1 on/off Cmd/blah blah/power1 on/off
And for channel 2
Stat/blah blah/power2 on/off Cmd/blah blah/power2 on/off
So for each of the virtual switches in ST u will create a device entry in devices.yml and subscribe to the appropriate topics on the right channel number - no different than a 2 channel device - just have to repeat the process 6 times instead of 2
echo what sandeep said...
I have 2, 3 and 4 channel devices working fine.
you have to just set up the devices.yml with each channel being an individual device.
you need to check how MQTT sends the message but typically with tasmota it is POWER
Ok than you guys
I am curious however, what is the use of the custom device handlers in groovy code if we can setup devices in the yml config file and default virtual switches ?
The custom device handlers are pulling in tasmota specific code - like custom LWT to check device health (online/offline) and then I pull a bunch of other tasmota specific information - look at the image below
But if u r just interested in basic capabilities then that should do. If you want the view as the image instead of ST virtual switch use the tasmota switch or the combo tasmotasensorswitch provided.
So the DTH provided should cover the most basic scenarios of switches and contact sensors populated with tasmota specific info
Thanks ! I just edited the devices.yml config file but i don't see subscription in the log file. Do I also need to register the device in the MQTT bridge smartapp ?
yes in the smartapp you need to select and register devices you want to be controlled through the bridge. open the smartapp and go through the config menu - remember to configure the bridge correctly and then register the bridge and devices with the smartapp
Just saw the line : deviceconfig: true
Ok another question, I created a device handler with 6 attributes :
(1..6).each { n ->
attribute "switch$n", "enum", ["on", "off"]
command "on$n"
command "off$n"
}
In the devices.yml :
subscribe:
switch1:
blablabla/stat/power1:
command:
'OFF': 'off1'
'ON': 'on1'
publish:
switch1:
blablabla/cmnd/power1:
retain: 'false'
I don't seem to get subscribed ...
Any way to have it work or I need to create 1 device = 1 outlet ? I have 3 power strips with 6 outlet each ... that makes a lot of devices ....
Thanks again.
Edit, I get in the log file :
2019-11-26 22:33:33 PM info: ============================ALL POSSIBLE SUBSCRIPTIONS FROM ALL EXTERNAL DEVICES =========================================== 2019-11-26 22:33:33 PM info: Subscription ***/Network_Power_1/stat/power1 [Network_Power_1],[switch1],[{"OFF":"off1","ON":"on1"}] 2019-11-26 22:33:33 PM info: ============================================================================================================================
Lets see its not clear
I think you did the the 1st one - it might be better for you two do the 2nd one. I will first describe the 2nd approach which should be straight forward and then describe for custom DTH which is more complex.
So for 6 individual outlets your device,yml should look like this
I am not seeing a device name in your devices.yml
devices.yml
---
Outlet1:
subscribe:
switch:
smartthings/stat/sonoff1/POWER1:
command:
'OFF': 'off'
'ON': 'on'
publish:
switch:
smartthings/cmnd/sonoff1/POWER1:
retain: 'false'
Outlet2:
subscribe:
switch:
smartthings/stat/sonoff1/POWER2:
command:
'OFF': 'off'
'ON': 'on'
publish:
switch:
smartthings/cmnd/sonoff1/POWER2:
retain: 'false'
Outlet3:
subscribe:
switch:
smartthings/stat/sonoff1/POWER3:
command:
'OFF': 'off'
'ON': 'on'
publish:
switch:
smartthings/cmnd/sonoff1/POWER3:
retain: 'false'
Outlet4:
subscribe:
switch:
smartthings/stat/sonoff1/POWER4:
command:
'OFF': 'off'
'ON': 'on'
publish:
switch:
smartthings/cmnd/sonoff1/POWER4:
retain: 'false'
Outlet5:
subscribe:
switch:
smartthings/stat/sonoff1/POWER5:
command:
'OFF': 'off'
'ON': 'on'
publish:
switch:
smartthings/cmnd/sonoff1/POWER5:
retain: 'false'
Outlet6:
subscribe:
switch:
smartthings/stat/sonoff1/POWER6:
command:
'OFF': 'off'
'ON': 'on'
publish:
switch:
smartthings/cmnd/sonoff1/POWER6:
retain: 'false'
make sure you go to smartapp on your phone select the switches and bridge in config. that should do it - if the bridge is configured properly and connecting with server
the other approach if you are creating a custom device handler with 6 attributes and custom on / off implementations that means you will have to code your own device handlers and specific methods in DTH and smartapp - if that is here's a summary of what you will need to do
Create a custom device handler. I am assuming since you will have at least 6 tiles with custom on/off implementations and all of them cannot have the same name you will have to code all of these?
Is this what you are attempting to do? there are many different ways to go about how you do custom implementation.
You will have to define six attributes in the DTH. But in the smartapp you can choose whether you want to action methods to be invoked for each of the attributes and expose them to the smart app or have all your smartapp commands routed to a processMQTT like handler function that you implement within the DTH and have it managed within the device.
I would suggest go with the easy approach first and make sure everything is connecting/working and then try to build the custom DTH.
For simplicity try only one channel for now and make sure that you can control that. Its very easy to add additional channels and even custom devices later but troubleshooting with custom DTH maybe difficult
once you get familiar with 1 channel i can walk your through how to create a custom DTH for 6 channel. In fact if you send me what your specific channel# subscribe and publish topics and payloads look like i can probably easily create a custom DTH for you - are you trying to create one device to control 6 channels or worried about creating 6 x 3 = 18 devices.
for the latter you can either create a parent device or parent smartapp to create 18 instances of child device using something like
addChildDevice("smartthings", "Virtual Switch", customDeviceID, hubID, [label: customlabel, name: customlabel, completedSetup: true])
your label and device id can be dynamically generated based on the channel numbers
that should automate that process somewhat
the approach you are taking of defining 6 unique attributes you would need to define a new capability in the capability maps with each of the attributes that for which you want the smartapp to trigger action commands and then define the action commands themselves. Check tasmotaswitch or tasmotaswitchsensor example and look in the beginning of smartapp code for the capability map definitions.
DId you get this working?
I have a Sonoff 3 channel switch, and it works perfectly. I did one switch device per channel to give me 3 switches. (I prefer not to have all 6 on the same device)
Similarly I have a Shelly 4 pro which has 4 channels. Here I was had to change the device.yml slightly and because I am looking at power and energy, I wrote a custom handler in the SmartApp and the device handler had to be modified a lot to parse the message for the new stuff.
Again the approch is 1 device per channel. NOT 1 device to manage all the channels.
As said above is the problem that you dont want one device per channel? Because there are pros and cons to everything. I was discussing fan controllers elsewhere, and the approach by many is to separate the light from the fan, making them different devices. This is because people want to control them independantly as different devices. I guess if everything is being automated in webcore it doesnt matter, but using the app, different people have different preference and styles to work. Neither way is right or wrong, just different pros and cons.
Anyway, hope you get it working. Personally I am moving all my tasmota and shelly devices over to the method of control because I prefer it to the Bret solution. Its given me some extra features I prefer... but again that is style and choice.
Hi @rhamblen,
Thanks for the update ! I was out of time this week but I will give it another shot this weekend !
For now, I am still in favor of 1 device = 6 channel, will let you guys know
Thanks
Hi to all,
It works perfectly fine now. Had to create a custom device handler for my power strip, modified the MBS smartapp and also edited devices.yml.
Let me know if you want the code (real simple) or maybe you would like to integrate on future releases.
Thanks again !
Any plans on releasing support for a 6-channel switch device ?
I flashed my Geeni Power strip : https://blakadder.github.io/templates/geeni_GN-SW003.html
Would like to be able ton control power1, power2, etc. from MQTT
Thanks