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


HC3 QuickApps coding - tips and tricks


jgab

Recommended Posts

all,

I have a problem with my QA before the latest upgrade it was working now it is not.

I have a QA with two buttons for turnon and turnoff device.

This working ok when i push the buttons.

I do a http request to the QA.

http://yyyyy:[email protected]/api/plugins/callUIEvent?deviceID=226&elementName=button1&eventType=onReleased.

 

My QA is simple

 

function QuickApp:onInit()
    self:debug("onInit")
end
 
function QuickApp:uibutton1OnReleased(event)
fibaro.call(217'turnOn'-- vitrinelamp aan
end
 
function QuickApp:uibutton2OnReleased(event)
fibaro.call(217'turnOff'-- vitrinelamp uit
end
 
When i send the request to the QA i see in the debug window the following.
 
[15.04.2020] [09:51:11] [TRACE] [QUICKAPP226]: UIEvent: {"deviceId":226,"values":[],"eventType":"onReleased?","elementName":"button1"}
[15.04.2020] [09:51:11] [WARNING] [QUICKAPP226]: UI callback for element: button1 not found.
 
please can anyone help me solve and explain what i am doing wrong
thanks
 
Edited by RobS
Link to comment
Share on other sites

And just with a Fibaro.call ?

Link to comment
Share on other sites

11 hours ago, RobS said:

[15.04.2020] [09:51:11] [TRACE] [QUICKAPP226]: UIEvent: {"deviceId":226,"values":[],"eventType":"onReleased?","elementName":"button1"}

[15.04.2020] [09:51:11] [WARNING] [QUICKAPP226]: UI callback for element: button1 not found.

 

 

Probably "?" sign at end of the call? must be

 

EDIT: yes, it is, when i call
 

Please login or register to see this link.

 

same error as yours

 

Please login or register to see this image.

/monthly_2020_04/image.png.987f4ea6ac960ed6fcc180ffe1660b53.png" />

Edited by tinman
Link to comment
Share on other sites

3 hours ago, tinman said:

Please login or register to see this link.

 

Sorry but i don't understand why use /api/plugins/callUIEvent, simply call the QA method with a  fibaro.call(62, "uibutton2OnReleased") to do the job

Link to comment
Share on other sites

1 minute ago, Krikroff said:

 

Sorry but i don't understand why use /api/plugins/callUIEvent, simply call the QA method with a  fibaro.call(62, "uibutton2OnReleased") to do the job

 

but not when you call it from external source, i assume he is trying to do it. If not, it does not make sense, for sure.

Link to comment
Share on other sites

correct,

I do the call from an external source.

I think i have solved the problem.

In the device i do the call i use the GET (query) function.

and i have to leave the second part of that function blank not even a space. now its works.

thanks anyway

 

 

Link to comment
Share on other sites

15 hours ago, tinman said:

but not when you call it from external source, i assume he is trying to do it. If not, it does not make sense, for sure.

 

Please login or register to see this link.

 ? It was obvious, sorry !!! 

Link to comment
Share on other sites

  • Topic Author
  • The new version of the

    Please login or register to see this link.

    supports child devices. To try it out I made a version of a Hue QuickApp.

    It is of type device controller and has an "install" button that creates child devices for Hue devices found.

    At the moment it supports 

            ["com.fibaro.remoteController"]  = ZLLSwitch,
            ["com.fibaro.temperatureSensor"] = ZLLTemperature,
            ["com.fibaro.motionSensor"]      = ZLLPresence,
            ["com.fibaro.lightSensor"]       = ZLLLightLevel,
            ["com.fibaro.colorController"]   = Extended_color_light,

    It's because that's the Hue devices I have :-) For other types of devices it will just log that they couldn't be installed.

     

    'ZLLSwitch' is a subclass of 'QuickAppChild' etc.

     

    Hue_IP, and Hue_User quickAppVariables need to be set to point to your Hue hub.

    The temperature, presence, light level behaves quite ok.

    The switch tries to send centralScene events (keyId, keyAttribute} and behaves almost like a fibaro key fob. Hue switches behaves  bit strange so I'm not there completely.

    The extended color light can set colours and brightness and updates the UI if the light is changed with the Hue app... It's a bit difficult to convert between RGB and Hues HSB values...

    Anyway, the child devices are of the "right" types so they can be used from block scenes and exposes their capabilities.

    I'm planning to spend some more time on this QuickApp to iron out some of the misbehaviours (just realised the plugin.deleteDevice didn't behave as anticipated)

    In other words, it's not "production ready" but it works to demonstrate the concept...

     

    The advantage with having my own Hue QuickApp is of course that I can easily add more functions to control the lights in more interesting way beyond what the standard Hue plugin does...

     

    Please login or register to see this attachment.

    Maybe some can get some inspiration for their own child device development from the code...

     

    Some other "discoveries".

    -Accessing a quickAppVariable that doesn't exists ,with self:getVariable, generates a WARNING in the debug window  - that's just unnecessary...

    -Accessing a non existent quickAppVariable returns the empty string "", instead of nil - did that change in the latest fw?

    -'self' actually contains a copy of the QuickApp data struct. Ex. self.properties.quickAppVariables....

    -Would be nice with some documentation of the plugin.* functions - almost like /api/plugins but with some "additions"...

    -Child devices are convenient for devices belonging to a common server. However, for things like the Shelly where you talk directly to each device it's a more limited use - besides that your child devices get some better (but standardised) UIs for stuff like color control.

    Would be nice to have that on standard QuickApps too.

    Edited by jgab
    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

    gap

     

    Philips Hue GU10 White Ambience Downlight

     

    Can this model be supported?

    On 2020. 4. 17. at 오전 5시 28분, jgab said:

    The new version of the

    Please login or register to see this link.

    supports child devices. To try it out I made a version of a Hue QuickApp.

    It is of type device controller and has an "install" button that creates child devices for Hue devices found.

    At the moment it supports 

            ["com.fibaro.remoteController"]  = ZLLSwitch,
            ["com.fibaro.temperatureSensor"] = ZLLTemperature,
            ["com.fibaro.motionSensor"]      = ZLLPresence,
            ["com.fibaro.lightSensor"]       = ZLLLightLevel,
            ["com.fibaro.colorController"]   = Extended_color_light,

    It's because that's the Hue devices I have :-) For other types of devices it will just log that they couldn't be installed.

     

    'ZLLSwitch' is a subclass of 'QuickAppChild' etc.

     

    Hue_IP, and Hue_User quickAppVariables need to be set to point to your Hue hub.

    The temperature, presence, light level behaves quite ok.

    The switch tries to send centralScene events (keyId, keyAttribute} and behaves almost like a fibaro key fob. Hue switches behaves  bit strange so I'm not there completely.

    The extended color light can set colours and brightness and updates the UI if the light is changed with the Hue app... It's a bit difficult to convert between RGB and Hues HSB values...

    Anyway, the child devices are of the "right" types so they can be used from block scenes and exposes their capabilities.

    I'm planning to spend some more time on this QuickApp to iron out some of the misbehaviours (just realised the plugin.deleteDevice didn't behave as anticipated)

    In other words, it's not "production ready" but it works to demonstrate the concept...

     

    내 Hue QuickApp을 사용하는 것의 장점은 물론 표준 Hue 플러그인보다 더 재미있는 방식으로 조명을 제어하기 위해 더 많은 기능을 쉽게 추가 할 수 있다는 것입니다 ...

     

    Please login or register to see this attachment.

    어쩌면 일부는 코드에서 자신의 자식 장치 개발에 대한 영감을 얻을 수 있습니다 ...

     

    다른 "발견".

    self : getVariable을 사용하여 존재하지 않는 quickAppVariable에 액세스하면 디버그 창에 경고가 생성됩니다.

    존재하지 않는 quickAppVariable에 액세스하면 nil 대신 빈 문자열 ""이 반환됩니다.-최신 fw에서 변경 되었습니까?

    -'self '는 실제로 QuickApp 데이터 구조체의 사본을 포함합니다. 전의. self.properties.quickAppVariables ....

    -plugin. * 함수에 대한 문서가 좋을 것입니다-거의 / api / plugins와 비슷하지만 일부 "추가"가 있습니다 ...

    -자식 장치는 공통 서버에 속하는 장치에 편리합니다. 그러나 각 장치와 직접 대화하는 Shelly와 같은 경우에는 하위 장치가 색상 제어와 같은 항목에 대해 더 나은 (그러나 표준화 된) UI를 얻는 것 외에는 더 제한적으로 사용됩니다.

    표준 QuickApp에서도 마찬가지입니다.

    gap

     

    Philips Hue GU10 White Ambience Downlight

     

    Can this model be supported?

    Link to comment
    Share on other sites

  • Topic Author
  • 42 minutes ago, minsad79 said:

    Philips Hue GU10 White Ambience Downlight

    Can this model be supported?

    Try this version and click on the 'List' button of the main QA. It will list the available devices in the debug console. Tell me what 'type' your light is.

    If it's a non-RGB-color device I'm a bit unsure what type of child device I should create as it would need a "white temperature" slider.

    Please login or register to see this attachment.

     

    Link to comment
    Share on other sites

    15 minutes ago, jgab said:

    Try this version and click on the 'List' button of the main QA. It will list the available devices in the debug console. Tell me what 'type' your light is.

    If it's a non-RGB-color device I'm a bit unsure what type of child device I should create as it would need a "white temperature" slider.

    Please login or register to see this attachment.

     

    List here

    dimmable light

    Please login or register to see this attachment.

     

     

    The currently created child device

    Matches my Hugh device,

    dimmable lights are not made

     

    Link to comment
    Share on other sites

  • Topic Author
  • 17 minutes ago, minsad79 said:

    List here

    dimmable light

    device

    Matches my Hugh device,

    dimmable lights are not made

     

    Ok, try this. I don't have a dimmable light so I'm flying blind here :-) 

    I've mapped it to a com.fibaro.multilevelSwitch - hope that works

    Please login or register to see this attachment.

    • Like 1
    Link to comment
    Share on other sites

    4 minutes ago, jgab said:

    좋아, 이것을보십시오. 나는 조광 가능한 빛이 없어서 여기서 장님을 날고있다:-) 

    com.fibaro.multilevelSwitch에 매핑했습니다.

    Please login or register to see this attachment.

    It was made so accurately

    Users in Korea say thank you

    Please login or register to see this attachment.

    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • There have been posts about getting triggers/events in QAs using the /refresStates API.

    This post is nothing new but wraps the logic in a 'SourceTrigger' class

    Please login or register to see this code.

     

    If we have this class we can use it like this

    Please login or register to see this code.

    The functions we define on SourceTrigger has the name <type>_<property>

    Please login or register to see this code.

    will be called with 'source triggers' of type {type='device', property='value' ...}

    If we define

    Please login or register to see this code.

    we will get all triggers of type {type='device', ...}

    For triggers without a 'property' field we only have the type.

    The intention is that the triggers should look like the sourceTriggers available for Scenes.

     

    If we need different trigger loops we can subclass 'SourceTrigger'

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

    Guest Freddan67

    *SOLVED*

    I fixed it, I uninstalled the app and reinstalled. Now it works without blame

     

    I do not get any values on either exercise sensor. None of the values appear. What am I doing wrong ?

     

    In Swedish when I saw that the developer was from sweden

    Jag får inte ut några värden på vare motionsensorn. Inte något av värderna visas sig. Vad gör jag för fel ?

    Please login or register to see this attachment.

    Edited by Freddan67
    Link to comment
    Share on other sites

  • Topic Author
  • 54 minutes ago, Freddan67 said:

    *SOLVED*

    I fixed it, I uninstalled the app and reinstalled. Now it works without blame

     

    I do not get any values on either exercise sensor. None of the values appear. What am I doing wrong ?

     

    I've updated the QA and fixed some bugs that can happen.... it also logs state changes for sensors in the console to get a better feeling for how it performs.

    Please login or register to see this attachment.

    • Thanks 1
    Link to comment
    Share on other sites

    Guest Freddan67
    1 hour ago, jgab said:

     

    I've updated the QA and fixed some bugs that can happen.... it also logs state changes for sensors in the console to get a better feeling for how it performs.

    Please login or register to see this attachment.

    Thanks. How to do if you just want to update for upcoming versions

    Link to comment
    Share on other sites

  • Topic Author
  • 59 minutes ago, Freddan67 said:

    Thanks. How to do if you just want to update for upcoming versions

    Install the new QA. Open it up in the editor (in the WEB GUI of the HC3) and cut and paste the content into the old QA, and save. Then delete the newly installed QA.

    Edited by jgab
    Link to comment
    Share on other sites

    Join the conversation

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

    Guest
    Reply to this topic...

    ×   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...