Uibuilder : range slider on mobile phone

I am having an issue using a range slider in uibuilder on a mobile phone.
The aim is to change the brightness of an ikea-tradfri-bulb.

This is mainly working using a Desktop-Browser or a Nexus-Tablet.
It does not work using a mobile phone.

While the value is returned correctly on any device, it seems that v-on:click is not fired on the mobile - but only using it within the range slider since v-on:click works (on the phone) when I use it in an on/off button.

The Desktop runs Linux Mint, the tablet Android 8.1 and the phone Android 7.1 (Lineage 14).

The (simplified) code I use:

index.html

...

<div class="slidecontainer">
  <b-form-input type="range" min="1" max="245" value="50" class="custom-range" id="range-1"  v-model="val_brght" @click="chng_brght"  >
</div>
<p> Value: {{  val_brght }} </p>

...

index.js

...
data:
        {
         ...
           val_brght: '',
},
...
methods:
        {
          chng_brght: function(event) {
          uibuilder.send( {'topic': 
          'zigbee/L1', 'payload': {'brightness' : this.val_brght} } )
        },
},
...

I am very unsure if this the correct way to control the brightness at all. I am new to node-red and I am not a dev - I have a rough understanding of coding and (some updated) knowledge in html/css; never used javascript before.

After spending some time using uibuilder most of the things I wanted to do are working great with the ability to customize the 'look and feel' - so thanks for this piece by the way!

I would be glad if someone could help me settle this issue...
Tanks in advance!

I've implemented similar sliders that do work on mobile. Rather than using v-on:click on the slider directly, have you thought about changing the slider into a component, and use v-on:input on the usage of the component? You could also try it directly on the slider, as v-on:input/@input gets triggered when the value in the v-model changes. Here's a snippet from my own uibuilder code, where I use the sliders specifically for brightness; I've only tested these on iOS, not on android however:

BrightnessSlider.vue:

<template>
    <div>
        <label :for="id">{{ label }}</label>
        <b-form-input :id="id" v-model="localValue" type="range" :min="min" :max="max" debounce="1000" number></b-form-input>
        <div class="mt-2" v-show="!is_minimal">Brightness: {{ localValue }}</div>
    </div>
</template>

<script>
    module.exports = {
        name: 'BrightnessSlider',
        props: {
            value: {
                type: Number,
                required: true,
            },
            min: {
                type: Number,
                default: 0
            },
            max: {
                type: Number,
                default: 100
            },
            id: {
                type: String,
                required: true
            },
            label: {
                type: String,
                default: ""
            },
            is_minimal: {
                type: Boolean,
                default: false
            },
        },
        computed: {
            localValue: {
                get() {return this.value},
                set(localValue) {this.$emit('input', localValue)}
            }
        }
    }
</script>

CompVerlichting.vue:

<template>
    <div id="Verlichting">
        <h2>Voorkamer</h2>
        <h2>Slaapkamer</h2>
        <b-table striped hover :items="lampen.filter(item => item.loc === 'slaapkamer')" :fields="fields" responsive="sm">
            <template v-slot:cell(show_details)="row">
                <b-button size="sm" @click="row.toggleDetails" class="mr-2">
                    {{ row.detailsShowing ? 'Hide' : 'Show'}} Details
                </b-button>
            </template>

            <template v-slot:cell(state)="row">
                <bootstrap-switch
                        :id="'switch-on-off-' + row.item.device.id"
                        v-model="row.value.on"
                        label="On?"
                        @change="$root.sendNR('uibuilder/verlichting', {device: row.item.device, state: row.item.state})"
                >
                </bootstrap-switch>
            </template>

            <template v-slot:row-details="row">
                <b-card>
                    <b-row class="mb-2" v-if="row.item.has_brightness">
                        <b-col sm="3" class="text-sm-right">Brightness: </b-col>
                        <b-col>
                            <brightness-slider
                                v-model="row.item.state.brightness"
                                :min="0"
                                :max="100"
                                :id="'brightness-' + row.item.device.id"
                                :label="row.item.name"
                                is_minimal
                                @input="$root.sendNR('uibuilder/verlichting', {device: row.item.device, state: row.item.state})"
                            >
                            </brightness-slider>
                        </b-col>
                    </b-row>

                    <b-button size="sm" @click="row.toggleDetails">Hide Details</b-button>
                </b-card>
            </template>
        </b-table>
    </div>
</template>

<script>
    module.exports = {
        name: 'CompVerlichting',
        data() {
            return {
                lampen: [
                    {
                        loc: 'voorkamer',
                        device: {
                            id: '...',
                            type: 'zwave'
                        },
                        has_brightness: true,
                        name: 'Plafondlamp',
                        state: {
                            on: false,
                            brightness: 0,
                        }
                    },
                    {
                        loc: 'slaapkamer',
                        device: {
                            id: 'kastverlichting',
                            type: 'zigbee'
                        },
                        has_brightness: true,
                        name: 'Kastverlichting',
                        state: {
                            on: false,
                            brightness: 0,
                        }
                    },
                    {
                        loc: 'slaapkamer',
                        device: {
                            id: 'nachtlampje',
                            type: 'zigbee'
                        },
                        has_brightness: true,
                        name: 'Leeslampje bed',
                        state: {
                            on: false,
                            brightness: 0
                        }
                    },
                ],
                fields: [
                    {
                        key: 'name',
                        sortable: true,
                    },
                    {
                        key: 'state',
                        label: 'On/Off'
                    },
                    {
                        key: 'show_details',
                    }
                ]
            };
        },
        components: {
            'brightness-slider': httpVueLoader('./BrightnessSlider.vue'),
            'bootstrap-switch': httpVueLoader('./BootstrapSwitch.vue')
        }
    };
</script>

Please ignore the rest of this second component, it's a temporary setup that is about (when I can find the time) to be completely overhauled. In here, $root.sendNR is a method defined on the outermost part of the Vue app, so that I can call it from child components. It takes the format topic, payload.

2 Likes

Dear afelix,

v-on:input/@input did the trick!
Now I can change the brightness using the Android-phone as well!

I was already wondering if there was an alternative for @click but I did not find that. Still I am digging through tutorials to figure all the capabilities of node-red, uibuilder, javascript, vue...

By now I'll keep using it directly in the slider. The solid solution you're suggesting looks very...elaborated. It will take some time until I get there since I am not familiar with using components yet; I'll have to figure the concept of props and so on...but I am confident that this comes with some time... Your post is very inspiring!

Thank you very much for your hint! You really made my day : )
So nice that there are smart, kind and helpful people like you!

Happy anniversary, btw : )

2 Likes

Welcome to the community and to Node-RED, uibuilder, VueJS, etc.

Always nice to get kind words back from people.

I think Lena has about the most experience with VueJS on the forum. And may well know uibuilder as well (or better!) than I do. :smile:

Have fun, keep learning and shout out if there is anything we can help with.

1 Like

Any more questions, feel free to ask. I've been using Vue primarily since 2016 I think, for most of my web interfaces, though most were created on top of Python, Uibuilder now allows me to continue on that road with Node-RED as well.

1 Like

Oooh :thinking: Lodged firmly in the memory banks "Lena is a Vue expert"


off to prepare a list of questions

And Ansible. I think it was she that posted about Ansible which led me to look into it, for which I am eternally grateful (well maybe not eternally, I don't have any great hopes of lasting that long) and I am sure that if I got stuck she would be a mine of useful information :slight_smile:

1 Like

Dear all,
I really feel warmly welcomed now : )

When I stumbled across this, I had some (little) experience in other home-automation-systems. With uibuilder I found something that lets me do what I like to do - customizing things. Combined with the philosophy of open-source and the idea to communicate to share knowledge and ideas this is not only technically but socially interesting.

And as named in 'TotallyInformation' - things are explained well and patiently. Seeing the additionally wisdom and the same patience of others (like above) this is very motivating to continue with ideas and projects : )

Next thing for me will be the journey to colour lights; I'll see when I find the time and how far I get. Maybe I will start a new topic on that when I'm stuck.

But that brings me to some general questions:

  • what is the preferred way to lable uibuilder-related topics - uibuilder.. [uibuilder]... or sth. similar?
  • what is the preferred way to address people? The name on top of the post or - if existent - from the profiles (e.g. afelix / Lena ; TotallyInformation / Julian / Mr. Knight : ) ?

So, see you (randomly) around - looking forwards it!

And, of course, happy birthday afelix !

2 Likes

:smile: That's exactly why I built is as well.

I did create a proof-of-concept for working with SVG in uibuilder. You should be able to find the component on my GitHub. There is an example flow somewhere though I'm afraid I can't quite remember whether I put it in flows or here in the forum.

Interesting question. Never really come up before. I guess that anything that starts with uibuilder will be reasonably visible whether in brackets or with a trailing colon or space dash. Though I am keen that people spell it all lower case.

Well, I can't speak for others of course. But I'm happy to be called anything reasonably polite :smile: Julian is fine. I try to refer to people by name if I can as it feels more friendly to me. Of course, most of the people on the forum are based in Western cultures and we generally tend to be less formal.

Yes generally we use the @user name the person chose as that is how they choose to appear on the forum - so always a good starting place.

I just realised that this can be read as two different ways. When it comes to forum topics on here, either works fine. [Uibuilder] or Uibuilder : (like you did here) with the category set to "dashboard" would show that it's about a visual dashboard-like interface, but specifically within the node "uibuilder". That way, you will get less responses from people who answer from a node-red-dashboard perspective, but would categorise the uibuilder topics pretty well too.
The other interpretation is for the use of topics in Node-RED flows. I use my normal series of topics that I use in other parts of the aspect, but prepend this with an outer level uibuilder/ so that in my flows I know that these messages are related to the control I/O of uibuilder. Once I'm properly sending them forward beyond the uibuilder node, I often take a change node with some JSONata foo, to cut off the uibuilder/ prefix from the topic, and have it pass further through the flows with the regular syntax.

As Dave (dceejay) says just above this response, in general we pick the @user name. For some people, we've become familiar with each other through our time here on the forum, and might refer to each other in responses with a given name. When I specifically need the attention of a person I use the @user version, as that will give them a notification. If I'm referring to earlier additions to a post and I don't need their attention but I'm hoping the user I'm responding to understands who I mean, I use the @user part without the @ prefix. When a person is new to the forum, when I first respond to their topic I'll look at their profile first to see if they filled in the optional "name" part and might greet them with that name for a more personal approach. As one of the ways to register here is through Github, the username will be set automatically to their Github handle, but if it's their first post and they've taken the time to fill in the profile information already, I can take that extra time to try a personal approach too. I do notice that sometimes I refer to other users with a given name when trying to refer to something they did or made, and that other users don't understand who I mean, and mentioning it as user without the @ prefix instead would have been better. It's a learning process :slight_smile:

Thank you very much for clarifying. This helps me to get familiar with things...
And thank you Julian - I think I saw your post on the svg-floorplan (for some big house ; ) I'll recheck...

Cheers!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.