Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Question

Posted

Are there any examples of integration into Weatherflow HC3?

Or a quick app?

Recommended Posts

  • 0
Posted

Hi @pflugj,

 

please try this version

Please login or register to see this attachment.

  • Thanks 1
  • 0
Posted

I installed your Version but I have a problem.
Even though the QA is ~48KB  but when clicking on "Edit" the file ends at line 176 and the QA is not running.
 

I currently run a different listen.py command line:
nohup python3 /usr/local/bin/listen.py -b 127.0.0.1 -m --influxdb --influxdb_db=weather --influxdb_user=mqtt --influxdb_pass=mqtt -M

 

The -M option at the end of the command line takes care of multiple sensors and
therefore the topics at the MQTT server are different:

 

The main Topic is "sensors" and the different sensors are in a subtopic with the serial numbers like so:
"Sky" topic is in "SK-'serial'"
"Air" topic is in "AR-'serial'"
"Hub" topic is in "HB-'serial'"

the NEW Tempest Sensor is in
¨ST-serial"

 

To take care of that I added the following to your current QA
-- From here ADDED FOR MQTT MULTISENSOR
local multisensors  = true
local serial_hub      = "HB-00014678"        --obviously change to your serials
local serial_air        = "AR-00017126"        --obviously change to your serials
local serial_sky      = "SK-00009405"        --obviously change to your serials

local main_topic = ""
if multisensors == true then main_topic = "sensors/" else main_topic ="wf/" end
print ("Main Topic:", main_topic)
local hub_topic = ""
local air_topic = ""
local sky_topic = ""
if multisensors == true
    then
        hub_topic = main_topic .. serial_hub .. "/wf/"
        air_topic = main_topic .. serial_air .. "/wf/"
        sky_topic = main_topic .. serial_sky .. "/wf/"
    else
    hub_topic = "wf/"
    air_topic = "wf/"
    sky_topic = "wf/"
end
print ("Hub Topic:", hub_topic)
print ("Air Topic:", air_topic)
print ("Sky Topic:", sky_topic)
-- UP to here CHANGED FOR MQTT MULTISENSOR

  • 0
Posted
8 hours ago, pflugj said:

I installed your Version but I have a problem.
Even though the QA is ~48KB  but when clicking on "Edit" the file ends at line 176 and the QA is not running.
 

I currently run a different listen.py command line:
nohup python3 /usr/local/bin/listen.py -b 127.0.0.1 -m --influxdb --influxdb_db=weather --influxdb_user=mqtt --influxdb_pass=mqtt -M

 

Hi,

there is several files in this QA.

 

Please login or register to see this attachment.

 

that's enough to use only data from http and not use UDP Listener.

 

variables in file var

udpListenerPresent  = false
weatherFlowStationID    = ''
HW_version          = "Tempest" -- "Tempest" -- "Air_Sky"

 

when you fill this data, then set variable in main file to true:

 

readyToGo         = false
 
 
  • 0
Posted

...and of course the "http" part is working ?
(This is the 1st time that I see more than 1 file in a QA  ? thanks for this)

 

Unfortunately internet here isn't very reliable and I would prefer to use the local MQTT server.

Will you be able to implement the MQTT part (with "Multisensor Option")?

...and of course I am willing to test and try any upcoming version.

 

So far I have been using both QA's,
"Bodyarts" and your QA and stored for example the "Solar Radiation" values in a global var to trigger other things.
I am using this to estimate the available "Solar Power" and switch devices like Aircons ON or OFF depending on this values
(I am NOT connected to the grid and run on solar power only)

 

I personally prefer to use the one retrieved via MQTT as it not depending on internet connection and values are immediately updated when they change.


thanks and all the best from Namibia
Jurgen

PS: I suggest some cosmetic change for the Solar Radiation Unit:
instead of just "W" change the unit to "W/m²"

  • 0
Posted

I might have found a small bug.
In Tempest Mode there is a child named "wf battery air".

The value displayed stays at "0V"   

 

thanks and best regards from Namibia
Jurgen


PS: May I suggest another cosmetic change for the "air density¨
Add the unit "kg/m³"

  • 0
Posted

 Hi, @pflugj 

 

I think you understand me wrong. current QA CAN work in MQTT mode.

You need to edit variable to "true" value :

 

 

udpListenerPresent  = true
 
and then set mqtt host address:
 
hostMQTT              = "XXX.XXX.XXX.XXX"
 
Could you please try this.


>> I might have found a small bug.
>> In Tempest Mode there is a child named "wf battery air".

>> The value displayed stays at "0V"   

   

   Yes, I know about this. it happens because battery data available only in MQTT mode and in HTTP it's always stay 0 V because of no data.

   will fix it later, please ignore it now or switch to MQTT mode

 

those changes will be implemented soon, thanks for your feedback:

 

 - Solar Radiation Unit:  instead of just "W" change the unit to "W/m²"

- "air density¨ - Add the unit "kg/m³"

 

 

  • 0
Posted

Hi.
I do understand that MQTT is working ;-)
and I can confirm that the http part is working too ?
... but in my case the MQTT part  will not work without modifications ;-(

 

I am running a different listener.py command line,
because I am storing the UDP data to MQTT and InfluxDB and use the data in Grafana!

listen.py -b 127.0.0.1 -m --influxdb --influxdb_db=weather --influxdb_user=mqtt --influxdb_pass=mqtt -M

 

By adding the "-M" option to the listener, MQTT publishes the sensors in different topics.
This way it is possible to distinguish between multiple sensors.

 

The main MQTT Topic changes from "wf/" to "sensors" and the different sensors are in a subtopic with the serial numbers like so:

sensors/ST-xxxxxxxxx/wf  --where "xxxxxxxx"is the serial number of the device

sensors/SK-xxxxxxxxx/wf

sensors/HB-xxxxxxxxx/wf

sensors/AR-xxxxxxxxx/wf

 

Therefore I changed your previous QA slightly and added a few things to take care of the topic changes.

 

Right after the MQTT hostIP definition ( Line 29) I added 

-- From here ADDED for MQTT MULTISENSOR
local multisensors  = true
local serial_hub      = "HB-00014678"       --obviously change to your serials
local serial_air        = "AR-00017126"        --obviously change to your serials
local serial_sky      = "SK-00009405"       --obviously change to your serials

local main_topic = ""
if multisensors == true then main_topic = "sensors/" else main_topic ="wf/" end
print ("Main Topic:", main_topic)
local hub_topic = ""
local air_topic = ""
local sky_topic = ""
if multisensors == true
    then
        hub_topic = main_topic .. serial_hub .. "/wf/"
        air_topic = main_topic .. serial_air .. "/wf/"
        sky_topic = main_topic .. serial_sky .. "/wf/"
    else
    hub_topic = "wf/"
    air_topic = "wf/"
    sky_topic = "wf/"
end
print ("Hub Topic:", hub_topic)
print ("Air Topic:", air_topic)
print ("Sky Topic:", sky_topic)
-- UP to here ADDED for MQTT MULTISENSOR

I also changed the function:

   local function onConnect(event)
        self:debug("connected: "..json.encode(event))

        self.client:addEventListener('subscribed', function(event) onSubscribed(event) end)
        self.client:addEventListener('message', function(event) onMessage(event) end)

        self.lastUpdateMQTT = os.time()
        -- if event.topic == "/evt/precip" then -- wf/evt/precip
        if event.topic == air_topic .."evt/precip" then -- wf/evt/precip        -- CHANGED FOR MQTT MULTISENSOR

 

I also changed the function:

function QuickApp:getWFmqttData()

    local function onSubscribed(event)
        self:debug("subscribed: "..json.encode(event))
    end

    local function onMessage(event)
--        self:debug("onMessage: "..json.encode(event))
--        self:trace("onMessage, event = "..tableToString(event))
--          self:trace("Topic received:", event.topic)

--        if event.payload == nil or event.topic == nil or not event.topic then
--            self:warning("MQTT data is nil. Exiting from function now...")
--            return
--        end

        self.lastUpdateMQTT = os.time()
        -- if event.topic == "/evt/precip" then -- wf/evt/precip
        if event.topic == air_topic .."evt/precip" then -- wf/evt/precip        -- CHANGED FOR MQTT MULTISENSOR
-- catch event "Rain Start" - topic "evt" with data: precip = {"timestamp": xxx }

            local evt = json.decode(event.payload)
--            self:warning (evt.timestamp)
-- todo: send push "Event: Rain Start".. evt.timestamp

            child1 = self.childDevices[self.childDevicesList.precip_accum_last_1hr.id]
            child2 = self.childDevices[self.childDevicesList.precip_minutes_local_day.id]
            child1:updLog("started @"..os.date("%H:%M", evt.timestamp))
            child2:updLog("last ? @"..os.date("%H:%M", evt.timestamp))

        -- elseif event.topic == "wf/obs_air" or event.topic == "wf/obs_sky" then
        elseif event.topic == air_topic.."obs_air" or event.topic == sky_topic.."obs_sky" then        -- CHANGED FOR MQTT MULTISENSOR
            local wf = json.decode(event.payload)
--            self:trace('mqtt data = '..json.encode(wf))

            for topic2, value in pairs(wf) do
                local start , stop = string.find(event.topic, "wf/")    -- CHANGED/ ADDED FOR MQTT MULTISENSOR
                local rest =  string.sub(event.topic , stop + 1 )        -- CHANGED/ ADDED FOR MQTT MULTISENSOR
                -- print ("Rest string: ".. rest)
            
                for metricName, childDevData in pairs(self.childDevicesList) do
                --    if string.gsub(event.topic,"wf/","").."/"..topic2 == childDevData.topic and childDevData.comm == "mqtt" then
                    if rest .."/"..topic2 == childDevData.topic and childDevData.comm == "mqtt" then     -- CHANGED/ ADDED FOR MQTT MULTISENSOR
                        childDevData.value = tonumber(value)
                        self:trace('child',"[ "..childDevData.id.." ] "..childDevData.name.." value is "..childDevData.value)
                        child = self.childDevices[childDevData.id]
                        child:setValue(childDevData.value)
                    end
                end
            end
--- rain and wind detailed calculations
        --if event.topic == "wf/obs_sky" then
        if event.topic == sky_topic.."obs_sky" then        -- CHANGED/ ADDED FOR MQTT MULTISENSOR

 

As far as I can recall this was all I changed.

So far I did not make any changes to your BETA version and therefore MQTT does NOT work for me :-(

Thanks for your help ? and best regards
Jurgen
 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...