Second copy of MQTT Connector possible?

Posted on
Thu Apr 01, 2021 7:02 am
CliveS offline
Posts: 770
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Second copy of MQTT Connector possible?

I have modified the MQTT Connector plugin to allow my motorhome solar panel controller and battery shunt to pass details to Indigo to control when the mains charger is used and other triggers, works 100% so thank you.

obviously you don’t want to add ‘State Of Charge’,’ Days Remaining At Current Use’ or High/Low voltage Disconnect Alarm(which triggers a better email warning) to the plugin.

As I would rather not modify the files every time you update is it possible to copy the plugin and run a second copy without affecting the original so I can leave the copy as it is at present, it works and no need to upgrade it.

If it is then what would I need to change in MQTT Connector.indigoPlugin

Screenshot 2021-04-01 at 13.47.21.png
Screenshot 2021-04-01 at 13.47.21.png (193.96 KiB) Viewed 1206 times


CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Thu Apr 01, 2021 7:12 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Second copy of MQTT Connector possible?

What did you need to change in the Connector? Seems like all that could have been handled in the Shims plugin.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Apr 01, 2021 7:34 am
CliveS offline
Posts: 770
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: Second copy of MQTT Connector possible?

I am using Shims for them but just added to it to change kStateImageSel at set values, convert seconds to days and check for 0 or 2 for voltage alarms etc.

Code: Select all
                    <Option value="Voltage">Voltage (V)</Option>
                    <Option value="Current">Current (A)</Option>
                    <Option value="SOC">SOC</Option>                   
                    <Option value="TimeToGo">TimeToGo</Option>
                    <Option value="VoltageLowAlarms">VoltageLowAlarms</Option>
                    <Option value="VoltageHighAlarms">VoltageHighAlarms</Option>

and
Code: Select all

         elif device.pluginProps["shimSensorSubtype"] == "Voltage":
            precision = device.pluginProps.get("shimSensorPrecision", "2")
            device.updateStateImageOnServer(indigo.kStateImageSel.EnergyMeterOn)
            device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f} V'.format(value, prec=precision))

         elif device.pluginProps["shimSensorSubtype"] == "Current":
            precision = device.pluginProps.get("shimSensorPrecision", "2")
            device.updateStateImageOnServer(indigo.kStateImageSel.EnergyMeterOn)
            device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f} A'.format(value, prec=precision))

         elif device.pluginProps["shimSensorSubtype"] == "SOC":
            precision = device.pluginProps.get("shimSensorPrecision", "2")

            if value >= 20:
               device.updateStateImageOnServer(indigo.kStateImageSel.SensorOn)
               device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f}%'.format(value, prec=precision))
            else:
               device.updateStateImageOnServer(indigo.kStateImageSel.SensorTripped)
               device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f}%'.format(value, prec=precision))

         elif device.pluginProps["shimSensorSubtype"] == "TimeToGo":
            precision = device.pluginProps.get("shimSensorPrecision", "2")
            value=float(value/86400)
            if value >= 1.5:
               device.updateStateImageOnServer(indigo.kStateImageSel.SensorOn)
               device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f} Days'.format(value, prec=precision))
            else:
               device.updateStateImageOnServer(indigo.kStateImageSel.SensorTripped)
               device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f} Days'.format(value, prec=precision))

         elif device.pluginProps["shimSensorSubtype"] == "VoltageAlarms":
            precision = device.pluginProps.get("shimSensorPrecision", "0")
            if value == 2:
               device.updateStateImageOnServer(indigo.kStateImageSel.PowerOff)
               device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f}%'.format(value, prec=precision))
            else:
               device.updateStateImageOnServer(indigo.kStateImageSel.PowerOn)
               device.updateStateOnServer(key='sensorValue', value=value, decimalPlaces=int(precision), uiValue=u'{:.{prec}f}%'.format(value, prec=precision))

I am happy with that and would just like to make a copy but don't want to make the original unstable.

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Thu Apr 01, 2021 7:41 am
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Second copy of MQTT Connector possible?

You changed the Shim plugin, not the Connector, right? Because that looks like Shim code.

The voltage and current values are worth adding to the plugin, so if you create an issue in GitHub and include the code, I'll do that. The others seem too device or user specific to include.

To answer your original question - make a copy of the plugin, but give it a different name. The only other required change is to the bundle identifier in the Info.plist file:
Code: Select all
    <key>CFBundleIdentifier</key>
    <string>com.flyingdiver.indigoplugin.shims</string>


That also needs to be different, so that Indigo knows it's not the same plugin. You'll probably want to change the name as well, but it's not required:
Code: Select all
    <key>CFBundleName</key>
    <string>MQTT Shims</string>

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Apr 01, 2021 8:06 am
CliveS offline
Posts: 770
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: Second copy of MQTT Connector possible?

FlyingDiver wrote:
You changed the Shim plugin, not the Connector, right? Because that looks like Shim code.

Ah, yes, you noticed my error :oops:
FlyingDiver wrote:
voltage and current values are worth adding to the plugin, so if you create an issue in GitHub and include the code, I'll do that. The others seem too device or user specific to include.

Ok, will try, may end up in one of your other repositories with my track record !!
FlyingDiver wrote:
To answer your original question - make a copy of the plugin, but give it a different name. The only other required change is to the bundle identifier in the Info.plist file:
Code: Select all
    <key>CFBundleIdentifier</key>
    <string>com.flyingdiver.indigoplugin.shims</string>


That also needs to be different, so that Indigo knows it's not the same plugin. You'll probably want to change the name as well, but it's not required:
Code: Select all
    <key>CFBundleName</key>
    <string>MQTT Shims</string>

Thank you Joe

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests