Thank you elagache for the quick reply.
So I applied the code in the synthetic channel, as you mentioned. I am seeing the correct values in the synthetic channel config pane. I can also go to
Tools --> Custom Graphs --> New
or
Tools --> Custom Gauges --> New
and when I use the dropdown menu to select the input (Series 1, Series 2, Series 3), I do see the synthetic channels listed there, along with all the Station Hardware Options. I can create a graph or gauge and the rendered data looks correct, but it does not seem to be included with the other data via mqtt.
Below is the AppleScript I am using. Is there something in there (or not in there) that I'm missing that would keep the synthetic channel data from being pulled and included?
property _ucChars_ : "AÄÁÀÂÃÅĂĄÆBCÇĆČDĎĐEÉÈÊËĚĘFGHIÍÌÎÏJKLĹĽŁMNÑŃŇ" & ¬
"OÖÓÒÔÕŐØPQRŔŘSŞŠŚTŤŢUÜÚÙÛŮŰVWXYÝZŽŹŻÞ"
property _lcChars_ : "aäáàâãåăąæbcçćčdďđeéèêëěęfghiíìîïjklĺľłmnñńň" & ¬
"oöóòôõőøpqrŕřsşšśtťţuüúùûůűvwxyýzžźżþ"
tell application "WeatherCat"
-- Change these variables as you desire
set loopDelay to 60 -- 60 seconds
set mqttServer to "<Server IP>"
set mqttport to "<mqtt port>"
set mqttChannel to "<mqtt channel>"
set mqttuser to "<user>"
set mqttpassword to "<pw>"
set mqttQOS to "1"
set oldCurrentConditions to ""
set oldDriverStatus to ""
set quantum to 0.1 -- Used for rounding data to 1 decimal place
-- Initialise the previous values list
set previousValues to {} -- array/list of previous values
repeat NumberOfChannels times
set end of previousValues to ""
end repeat
repeat -- run around this loop forever, once every x seconds
-- Get the Current Conditions (text)
set currConditions to CurrentConditions
if oldCurrentConditions is not currConditions then
do shell script "/usr/local/bin/mosquitto_pub -h " & mqttServer & " -p " & mqttport & " -q " & mqttQOS & " -u " & mqttuser & " -P " & mqttpassword & " -t " & mqttChannel & "weather/lacostaweather/ -m " & quoted form of currConditions
end if
set oldCurrentConditions to currConditions
repeat with theIncrementValue from 1 to NumberOfChannels
set WorkingChannel to theIncrementValue
set wcname to WorkingChannelName
set wcvalue to (round (WorkingChannelValue / quantum)) * quantum
set wcstatus to WorkingChannelStatus
-- Set the previous value from the list
set wcpreviousvalue to item theIncrementValue of previousValues
-- If the WeatherCat channel is OK and the value has changed then publish
if wcname is not missing value and wcstatus is true and wcpreviousvalue is not wcvalue then
set wcnamecleaned to my replaceString(wcname, " ", "_")
set wcnamecleaned to my replaceString(wcnamecleaned, ".", "")
set wcnamecleaned to my replaceString(wcnamecleaned, "(", "")
set wcnamecleaned to my replaceString(wcnamecleaned, ")", "")
set wcnamecleaned to my lowerString(wcnamecleaned)
do shell script "/usr/local/bin/mosquitto_pub -h " & mqttServer & " -p " & mqttport & " -q " & mqttQOS & " -u " & mqttuser & " -P " & mqttpassword & " -t '" & mqttChannel & wcnamecleaned & "/' -m " & wcvalue
end if
set item theIncrementValue of previousValues to wcvalue
end repeat
delay loopDelay
end repeat
end tell
on replaceString(theText, oldString, newString)
set AppleScript's text item delimiters to oldString
set tempList to every text item of theText
set AppleScript's text item delimiters to newString
set theText to the tempList as string
set AppleScript's text item delimiters to ""
return theText
end replaceString
on lowerString(theText)
local upper, lower, theText
try
return my translateChars(theText, my _ucChars_, my _lcChars_)
on error eMsg number eNum
error "Can't lowerString: " & eMsg number eNum
end try
end lowerString
on translateChars(theText, fromChars, toChars)
local Newtext, fromChars, toChars, char, newChar, theText
try
set Newtext to ""
if (count fromChars) ≠ (count toChars) then
error "translateChars: From/To strings have different length"
end if
repeat with char in theText
set newChar to char
set x to offset of char in fromChars
if x is not 0 then set newChar to character x of toChars
set Newtext to Newtext & newChar
end repeat
return Newtext
on error eMsg number eNum
error "Can't translateChars: " & eMsg number eNum
end try
end translateChars